/* =============================================================================
   eddu Theme — main.css
   Global styles, CSS variables, typography, layout utilities
   ============================================================================= */

/* ─── CSS Custom Properties ─────────────────────────────────────────────────── */

:root {
    /* Colors */
    --color-bg:        #FAFAF9;
    --color-dark:      #111111;
    --color-accent:    #E85D26;   /* Warm orange — education energy, trust, action */
    --color-accent-lt: #FF7340;   /* Lighter tint for hover */
    --color-muted:     #6B6B6B;
    --color-border:    #E5E5E3;
    --color-surface:   #F0EFED;
    --color-white:     #FFFFFF;
    --color-dark-muted:#8A8A8A;   /* Muted text on dark backgrounds */
    --color-dark-border:#2A2A2A;  /* Border on dark backgrounds */

    /* Typography */
    --font-body:     'IBM Plex Sans Thai', sans-serif;
    --font-friendly: 'IBM Plex Sans Thai Looped', sans-serif;
    --font-premium:  'IBM Plex Serif', serif;

    /* Type Scale */
    --text-xs:   clamp(0.75rem,  1vw,    0.8125rem);
    --text-sm:   clamp(0.875rem, 1.2vw,  0.9375rem);
    --text-base: clamp(1rem,     1.4vw,  1.0625rem);
    --text-md:   clamp(1.125rem, 1.6vw,  1.25rem);
    --text-lg:   clamp(1.25rem,  2vw,    1.5rem);
    --text-xl:   clamp(1.5rem,   2.5vw,  2rem);
    --text-2xl:  clamp(2rem,     3.5vw,  2.75rem);
    --text-3xl:  clamp(2.5rem,   5vw,    4rem);
    --text-hero: clamp(3.5rem,   7vw,    6rem);
    --text-stat: clamp(4rem,     8vw,    7.5rem);

    /* Spacing */
    --section-padding:   clamp(80px, 10vw, 140px) 0;
    --container-max:     1200px;
    --container-padding: 0 clamp(20px, 5vw, 80px);
    --gap-sm:  clamp(12px, 2vw,  20px);
    --gap-md:  clamp(20px, 3vw,  32px);
    --gap-lg:  clamp(32px, 5vw,  56px);
    --gap-xl:  clamp(48px, 8vw,  80px);

    /* Borders */
    --radius-sm:  6px;
    --radius-md:  12px;
    --radius-lg:  20px;
    --radius-pill:9999px;

    /* Transitions */
    --transition-fast:   150ms ease;
    --transition-base:   250ms ease;
    --transition-slow:   400ms ease;
    --transition-spring: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 16px rgba(0,0,0,.08);
    --shadow-lg:  0 12px 40px rgba(0,0,0,.12);
    --shadow-xl:  0 24px 64px rgba(0,0,0,.16);

    /* Z-index layers */
    --z-base:    0;
    --z-raised:  10;
    --z-dropdown:100;
    --z-nav:     200;
    --z-modal:   300;
    --z-toast:   400;
}

/* ─── Reset & Base ───────────────────────────────────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.65;
    color: var(--color-dark);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

img, video, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

ul, ol {
    list-style: none;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font: inherit;
}

input, textarea, select {
    font: inherit;
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    font-weight: 700;
}

/* ─── Layout Utilities ───────────────────────────────────────────────────────── */

.container {
    max-width: var(--container-max);
    margin-inline: auto;
    padding: var(--container-padding);
    width: 100%;
}

.container--wide {
    max-width: 1440px;
}

.container--narrow {
    max-width: 800px;
}

.section {
    padding: var(--section-padding);
}

.section--dark {
    background-color: var(--color-dark);
    color: var(--color-white);
}

.section--surface {
    background-color: var(--color-surface);
}

/* ─── Typography ─────────────────────────────────────────────────────────────── */

.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-md    { font-size: var(--text-md); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }
.text-3xl   { font-size: var(--text-3xl); }

.font-body     { font-family: var(--font-body); }
.font-friendly { font-family: var(--font-friendly); }
.font-premium  { font-family: var(--font-premium); }

.font-light    { font-weight: 300; }
.font-regular  { font-weight: 400; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.italic     { font-style: italic; }
.uppercase  { text-transform: uppercase; }
.tracking   { letter-spacing: 0.08em; }
.tracking-wide { letter-spacing: 0.12em; }

.text-muted  { color: var(--color-muted); }
.text-accent { color: var(--color-accent); }
.text-dark-muted { color: var(--color-dark-muted); }

/* Section labels */
.section-label {
    display: inline-block;
    font-size: var(--text-xs);
    font-family: var(--font-body);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--color-muted);
    margin-bottom: 16px;
}

.section-label--dark {
    color: var(--color-dark-muted);
}

.section-label--accent {
    color: var(--color-accent);
}

/* Section heading */
.section-heading {
    font-size: var(--text-2xl);
    font-weight: 700;
    line-height: 1.18;
    margin-bottom: 16px;
}

.section-heading em {
    font-style: italic;
}

.section-sub {
    font-size: var(--text-md);
    color: var(--color-muted);
    line-height: 1.7;
    max-width: 560px;
}

.section-sub--dark {
    color: var(--color-dark-muted);
}

/* ─── Grid & Flex Utilities ──────────────────────────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap-md); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap-md); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap-md); }

.flex      { display: flex; }
.flex-col  { display: flex; flex-direction: column; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-sm { gap: var(--gap-sm); }
.gap-md { gap: var(--gap-md); }
.gap-lg { gap: var(--gap-lg); }

/* ─── Section Header Block ───────────────────────────────────────────────────── */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--gap-lg);
    flex-wrap: wrap;
    gap: var(--gap-md);
}

.section-header__content {}

.section-header__action {
    flex-shrink: 0;
}

/* ─── Divider ─────────────────────────────────────────────────────────────────── */

.divider {
    height: 1px;
    background: var(--color-border);
    margin: var(--gap-xl) 0;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 { grid-template-columns: 1fr; }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ─── Accessibility ───────────────────────────────────────────────────────────── */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
    border-radius: 3px;
}

/* ─── Skip Link ───────────────────────────────────────────────────────────────── */

.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: var(--color-accent);
    color: var(--color-white);
    font-weight: 600;
    border-radius: var(--radius-sm);
    z-index: var(--z-toast);
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 1rem;
}

/* ─── Noise texture overlay ──────────────────────────────────────────────────── */

.noise-overlay {
    position: relative;
}

.noise-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
}

.noise-overlay > * {
    position: relative;
    z-index: 1;
}
