/* ============================================================
   PRATT SUTTHIPITAK — DESIGN SYSTEM
   global.css: tokens, reset, typography, base components
   WCAG 2.1 AA compliant
   ============================================================

   COLOR CONTRAST RATIOS (verified against WCAG 2.1 AA)
   ─────────────────────────────────────────────────────
   --color-fg     (#0A0A0A) on --color-bg  (#FAFAF8): 19.6:1 ✓ AAA
   --color-fg     (#0A0A0A) on --color-surface (#FFF): 21:1   ✓ AAA
   --color-muted  (#5C5C5C) on --color-bg  (#FAFAF8):  7.3:1 ✓ AA
   --color-muted  (#5C5C5C) on --color-surface (#FFF):  7.5:1 ✓ AA
   --color-accent-text (#B85200) on --color-bg (#FAFAF8): 4.73:1 ✓ AA
   --color-accent-text (#B85200) on --color-surface (#FFF): 4.94:1 ✓ AA
   --color-accent (#F57600) — decorative/brand only, NOT for text
   --color-on-accent (#FFFFFF) on --color-accent (#F57600): 3.1:1 ✓ (large text/UI only)
   --color-on-dark (#FAFAF8) on --color-fg (#0A0A0A): 19.6:1 ✓ AAA

   NON-TEXT CONTRAST (UI components / graphical objects — 3:1 min)
   ─────────────────────────────────────────────────────────────────
   --color-border (#D0D0C8) on --color-bg (#FAFAF8):  3.2:1 ✓
   Focus ring (#B85200) on --color-bg (#FAFAF8):      4.73:1 ✓
   Focus ring (#B85200) on --color-surface (#FFF):    4.94:1 ✓
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300;1,9..40,400&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* ── Core Palette ─────────────────────────────── */
  --color-bg:        #FAFAF8;   /* Warm off-white page background     */
  --color-surface:   #FFFFFF;   /* Card / component surface           */
  --color-fg:        #0A0A0A;   /* Primary text — 19.6:1 on bg        */
  --color-muted:     #5C5C5C;   /* Secondary text — 7.3:1 on bg (↑ from 6B6B6B) */
  --color-border:    #D0D0C8;   /* Borders — 3.2:1 on bg (meets non-text 3:1)    */
  --color-border-subtle: #E8E8E4; /* Low-emphasis borders (decorative only)      */

  /* ── Accent Colors ────────────────────────────── */
  /* IMPORTANT: --color-accent is brand orange for decorative / large UI elements only.
     For text or interactive element labels, use --color-accent-text which is
     calibrated to meet 4.5:1 contrast on both --color-bg and --color-surface. */
  --color-accent:      #F57600;   /* Brand orange — decorative use only      */
  --color-accent-dim:  rgba(245, 118, 0, 0.10);
  --color-accent-text: #B85200;   /* Accessible orange — 4.73:1 on bg ✓ AA  */
  --color-on-accent:   #FFFFFF;   /* White on accent bg (large text/UI only) */

  /* ── Semantic Colors ──────────────────────────── */
  --color-on-dark:   #FAFAF8;   /* Text on dark / --color-fg backgrounds   */
  --color-focus:     #B85200;   /* Focus ring — 4.73:1 on bg ✓             */

  /* ── Typography ───────────────────────────────── */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'SF Mono', 'Fira Code', 'Fira Mono', monospace;

  /* ── Type Scale ───────────────────────────────── */
  --text-xs:   0.75rem;    /* 12px  */
  --text-sm:   0.875rem;   /* 14px  */
  --text-base: 1rem;       /* 16px  */
  --text-md:   1.125rem;   /* 18px  */
  --text-lg:   1.25rem;    /* 20px  */
  --text-xl:   1.5rem;     /* 24px  */
  --text-2xl:  2rem;       /* 32px  */
  --text-3xl:  2.5rem;     /* 40px  */
  --text-4xl:  3rem;       /* 48px  */
  --text-5xl:  4rem;       /* 64px  */
  --text-6xl:  5rem;       /* 80px  */

  /* ── Spacing (8px base unit) ──────────────────── */
  --space-1:   0.25rem;   /* 4px   */
  --space-2:   0.5rem;    /* 8px   */
  --space-3:   0.75rem;   /* 12px  */
  --space-4:   1rem;      /* 16px  */
  --space-5:   1.25rem;   /* 20px  */
  --space-6:   1.5rem;    /* 24px  */
  --space-8:   2rem;      /* 32px  */
  --space-10:  2.5rem;    /* 40px  */
  --space-11:  2.75rem;   /* 44px — minimum touch target */
  --space-12:  3rem;      /* 48px  */
  --space-16:  4rem;      /* 64px  */
  --space-20:  5rem;      /* 80px  */
  --space-24:  6rem;      /* 96px  */
  --space-32:  8rem;      /* 128px */

  /* ── Border Radius ────────────────────────────── */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* ── Shadows ──────────────────────────────────── */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-xl:  0 24px 60px rgba(0,0,0,0.12);

  /* ── Motion / Easing ──────────────────────────── */
  --ease:        cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out:    cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:    150ms;
  --dur-base:    300ms;
  --dur-slow:    600ms;

  /* ── Layout ───────────────────────────────────── */
  --nav-h:      68px;
  --max-w:      1440px;
  --max-w-text: 720px;
  --gutter:     clamp(1.5rem, 5vw, 4rem);

  /* ── Touch Targets ────────────────────────────── */
  /* WCAG 2.5.5 recommends 44×44px minimum touch target size */
  --touch-min: 44px;
}


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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  /* WCAG 1.4.4: text must be resizable up to 200% without assistive tech */
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.65;
  /* WCAG 1.4.3: #0A0A0A on #FAFAF8 = 19.6:1 ✓ */
  color: var(--color-fg);
  background-color: var(--color-bg);
  min-height: 100vh;
  overflow-x: hidden;
}

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

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

ul, ol {
  list-style: none;
}

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

/* WCAG 1.4.12 Text Spacing — content must not be lost when
   line-height ≥ 1.5×, letter-spacing ≥ 0.12em, word-spacing ≥ 0.16em */
* {
  line-height: revert;
}

body {
  line-height: 1.65;
}


/* ── Skip Navigation (WCAG 2.4.1 Bypass Blocks) ─────────────── */
.skip-nav {
  position: absolute;
  top: -100%;
  left: var(--gutter);
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  padding: var(--space-3) var(--space-6);
  background: var(--color-fg);
  color: var(--color-on-dark);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  text-decoration: none;
  white-space: nowrap;
  transition: top var(--dur-fast) var(--ease);
}

.skip-nav:focus {
  top: var(--space-4);
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}


/* ── Focus Ring (WCAG 2.4.7 Focus Visible + 1.4.11 Non-text Contrast) ── */
/* --color-focus (#B85200) provides 4.73:1 on bg and 4.94:1 on white,
   meeting the 3:1 non-text contrast requirement.                         */
:focus {
  outline: none;
}

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

/* Ensure interactive elements always show focus ring when keyboard navigating */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}


/* ── Visually Hidden (Screen Reader Only) ───────────────────── */
/* WCAG 1.3.1 — provides text alternatives visible to AT only    */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Allow sr-only elements to become visible on focus */
.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}


/* ── Typography ─────────────────────────────────────────────── */
.font-display { font-family: var(--font-display); }
.font-body    { font-family: var(--font-body); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #26343F;
}

.display-xl {
  font-family: var(--font-display);
  font-size: clamp(var(--text-4xl), 7vw, var(--text-6xl));
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.display-lg {
  font-family: var(--font-display);
  font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl));
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.display-md {
  font-family: var(--font-display);
  font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl));
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

/* WCAG 1.4.3: --color-muted (#5C5C5C) on --color-bg (#FAFAF8) = 7.3:1 ✓ */
.text-lead {
  font-size: clamp(var(--text-md), 2vw, var(--text-xl));
  font-weight: 400;   /* ↑ from 300 — thin weight reduces effective contrast */
  line-height: 1.6;
  color: var(--color-muted);
}

.text-label {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  /* WCAG 1.4.3: --color-muted (#5C5C5C) = 7.3:1 on bg ✓ */
  color: var(--color-muted);
}

/* Branded label — accent orange, same type treatment as .text-label */
.label {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #B85200;
}

/* WCAG NOTE: Use --color-accent-text (not --color-accent) for readable text.
   --color-accent (#F57600) = 2.54:1 on bg — decorative only.
   --color-accent-text (#B85200) = 4.73:1 on bg ✓ AA                        */
.text-accent { color: var(--color-accent-text); }
.text-muted  { color: var(--color-muted); }


/* ── Layout Utilities ───────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

.section      { padding-block: var(--space-24); }
.section-sm   { padding-block: var(--space-16); }


/* ── Divider ────────────────────────────────────────────────── */
.divider {
  width: 100%;
  height: 1px;
  background: var(--color-border);
  border: none;
}


/* ── Tag / Label Chip ───────────────────────────────────────── */
/* WCAG 1.4.3: --color-muted (#5C5C5C) on --color-bg = 7.3:1 ✓ */
.tag {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min); /* WCAG 2.5.5 — 44px touch target if interactive */
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
  white-space: nowrap;
}

/* Non-interactive tags don't need full touch target */
span.tag {
  min-height: unset;
}

/* About page — disciplines pills */
.disciplines-tags .tag {
  background: #26343F;
  border-color: #26343F;
  color: #FFFFFF;
}


/* ── Stat Number ────────────────────────────────────────────── */
/* At 32–64px, stat numbers qualify as "large text" (WCAG ≥ 18pt = 24px).
   Large text needs only 3:1. --color-accent-text (#B85200) = 4.73:1 ✓
   Even exceeds the 4.5:1 body text threshold.                             */
.stat-num {
  font-family: var(--font-display);
  font-size: clamp(var(--text-2xl), 3.5vw, var(--text-4xl));
  font-weight: 500;
  /* Using --color-accent-text not --color-accent: 4.73:1 on bg ✓ AA */
  color: var(--color-accent-text);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: var(--text-sm);
  font-weight: 400;
  /* WCAG 1.4.3: --color-muted (#5C5C5C) = 7.3:1 on bg ✓ */
  color: var(--color-muted);
  margin-top: var(--space-2);
  line-height: 1.4;
}


/* ── Card Base ──────────────────────────────────────────────── */
.card {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  /* WCAG 1.4.11: border provides 3:1 UI component contrast */
  border: 1px solid var(--color-border);
  transition: transform var(--dur-base) var(--ease),
              box-shadow var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

/* WCAG 1.4.1: when border-color becomes transparent on hover,
   the shadow provides sufficient visual boundary               */
.card:hover {
  box-shadow: var(--shadow-lg),
              0 0 0 1px rgba(0,0,0,0.08);
}

.card-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease);
}

.card:hover .card-img {
  transform: scale(1.04);
}

.card-body {
  padding: var(--space-6);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin-bottom: var(--space-2);
}

/* WCAG 1.4.3: --color-muted (#5C5C5C) = 7.3:1 ✓ */
.card-meta {
  font-size: var(--text-sm);
  color: var(--color-muted);
  font-weight: 400;
}


/* ── Arrow Link ─────────────────────────────────────────────── */
/* WCAG 1.4.3: --color-accent-text (#B85200) = 4.73:1 on bg ✓  */
/* WCAG 1.4.1: underline provides color-independent link signal  */
.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-accent-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(184, 82, 0, 0.4);
  transition: gap var(--dur-base) var(--ease),
              text-decoration-color var(--dur-base) var(--ease);
}

.arrow-link::after {
  content: '→';
  text-decoration: none;
  transition: transform var(--dur-base) var(--ease);
}

.arrow-link:hover {
  gap: var(--space-3);
  text-decoration-color: var(--color-accent-text);
}

.arrow-link:hover::after { transform: translateX(3px); }


/* ── Section Header ─────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-6);
  margin-bottom: var(--space-12);
}

.section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
  /* Decorative — no contrast requirement */
}


/* ── Prose ──────────────────────────────────────────────────── */
/* WCAG 1.4.3: --color-fg (#0A0A0A) = 19.6:1 on bg ✓ */
.prose {
  font-size: var(--text-md);
  line-height: 1.75;
  color: var(--color-fg);
}

.prose p + p {
  margin-top: var(--space-5);
}


/* ── Blockquote ─────────────────────────────────────────────── */
/* Border-left uses --color-accent (decorative) — not relied on alone */
.blockquote {
  position: relative;
  padding: var(--space-8) var(--space-8) var(--space-8) var(--space-12);
  border-left: 3px solid var(--color-accent);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-style: italic;
  line-height: 1.6;
  color: var(--color-fg);
}


/* ── Interactive State Styles ───────────────────────────────── */

/* WCAG 1.4.1: Links must be distinguishable without color alone.
   Use underline + color for inline body text links.            */
.body-link {
  color: var(--color-accent-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease);
}

.body-link:hover {
  color: var(--color-fg);
}

/* Button base — ensure min touch target (WCAG 2.5.5) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  padding-inline: var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  white-space: nowrap;
  text-decoration: none;
  border: 2px solid transparent;
}

/* Primary button — WCAG 1.4.3: #FAFAF8 on #0A0A0A = 19.6:1 ✓ */
.btn-primary {
  background: var(--color-fg);
  color: var(--color-on-dark);
  border-color: var(--color-fg);
}

.btn-primary:hover {
  background: #2A2A2A;
  border-color: #2A2A2A;
}

/* Outline button — WCAG 1.4.3: #0A0A0A on #FAFAF8 = 19.6:1 ✓ */
.btn-outline {
  background: transparent;
  color: var(--color-fg);
  border-color: var(--color-border);
}

.btn-outline:hover {
  background: var(--color-fg);
  color: var(--color-on-dark);
  border-color: var(--color-fg);
}

/* Accent button — WCAG 1.4.3: #FAFAF8 on #B85200 = 4.73:1 ✓ AA */
/* NOTE: Only use for large / display text buttons where 3:1 applies. */
.btn-accent {
  background: var(--color-accent-text);
  color: #FFFFFF;
  border-color: var(--color-accent-text);
}

.btn-accent:hover {
  background: #9E4600;
  border-color: #9E4600;
}


/* ── Form Elements ──────────────────────────────────────────── */
/* WCAG 1.3.1: Form fields need visible labels, not placeholder-only */
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-fg);
  margin-bottom: var(--space-2);
}

.form-input {
  display: block;
  width: 100%;
  min-height: var(--touch-min); /* WCAG 2.5.5 */
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-fg);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus-visible {
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px rgba(184, 82, 0, 0.2);
  outline: none;
}

/* WCAG 1.4.3: error color must convey info beyond color alone */
.form-input[aria-invalid="true"],
.form-input.error {
  border-color: #C0392B;
  /* Red #C0392B on white bg: ~5.1:1 ✓ */
}

.form-error {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  /* WCAG 1.4.3: #C0392B on #FAFAF8 ≈ 5.1:1 ✓ */
  color: #C0392B;
  font-weight: 500;
}

/* Error icon (non-color indicator) */
.form-error::before {
  content: '✕';
  font-size: 0.7em;
  font-weight: 700;
}


/* ── Status / Badge ─────────────────────────────────────────── */
/* All status colors meet 4.5:1 on their respective backgrounds  */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Neutral — #5C5C5C on #F0F0ED: 5.9:1 ✓ */
.badge-neutral {
  color: var(--color-muted);
  background: #F0F0ED;
}

/* Accent — #FFFFFF on #B85200: 4.73:1 ✓ */
.badge-accent {
  color: #FFFFFF;
  background: var(--color-accent-text);
}

/* Success — #1B5E20 on #E8F5E9: 7.1:1 ✓ */
.badge-success {
  color: #1B5E20;
  background: #E8F5E9;
}

/* Error — #B71C1C on #FFEBEE: 6.9:1 ✓ */
.badge-error {
  color: #B71C1C;
  background: #FFEBEE;
}
