/* ==========================================================================
   base.css — design tokens, reset, typography, layout primitives
   Chanelle Hazeltine · Marriage & Family Therapy · Bangkok
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Core palette — grounded, warm, clinical-but-human */
  --ink:        #101b1a;
  --ink-soft:   #2b3a38;
  --forest:     #17352f;
  --forest-mid: #23524a;
  --forest-lo:  #0e211d;
  --sage:       #7ba493;
  --sage-soft:  #a9c6b9;
  --sage-mist:  #dce8e2;
  --sand:       #efe6d9;
  --sand-deep:  #e2d5c3;
  --cream:      #fbf8f3;
  --paper:      #ffffff;
  --clay:       #bd6c4c;
  --clay-soft:  #dc9873;
  --gold:       #cf9f49;

  /* Semantic */
  --bg:            var(--cream);
  --bg-alt:        var(--sand);
  --surface:       var(--paper);
  --text:          var(--ink);
  --text-muted:    #5a6b68;
  --text-invert:   #eef4f1;
  --text-invert-muted: rgba(238, 244, 241, .68);
  --accent:        var(--clay);
  --line:          rgba(23, 53, 47, .12);
  --line-strong:   rgba(23, 53, 47, .22);
  --line-invert:   rgba(238, 244, 241, .18);

  /* Type */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-th-display: "Noto Serif Thai", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  --font-th-body:    "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;

  /* Fluid type scale */
  --fs-xs:  clamp(0.75rem,  0.73rem + 0.10vw, 0.815rem);
  --fs-sm:  clamp(0.875rem, 0.85rem + 0.12vw, 0.95rem);
  --fs-base:clamp(1rem,     0.96rem + 0.20vw, 1.10rem);
  --fs-md:  clamp(1.125rem, 1.06rem + 0.32vw, 1.30rem);
  --fs-lg:  clamp(1.35rem,  1.22rem + 0.62vw, 1.75rem);
  --fs-xl:  clamp(1.7rem,   1.44rem + 1.24vw, 2.55rem);
  --fs-2xl: clamp(2.1rem,   1.66rem + 2.10vw, 3.60rem);
  --fs-3xl: clamp(2.6rem,   1.84rem + 3.60vw, 5.10rem);

  /* Space */
  --sp-1: .25rem;  --sp-2: .5rem;   --sp-3: .75rem;  --sp-4: 1rem;
  --sp-5: 1.5rem;  --sp-6: 2rem;    --sp-7: 3rem;    --sp-8: 4rem;
  --sp-9: 6rem;    --sp-10: 8rem;
  --section-y: clamp(4rem, 2.4rem + 7vw, 8.5rem);

  /* Shape */
  --r-sm: 8px;  --r-md: 14px;  --r-lg: 22px;  --r-xl: 34px;  --r-pill: 999px;
  --arch: 50% 50% 8px 8px / 34% 34% 8px 8px;

  /* Shadow — soft, never harsh */
  --shadow-sm: 0 1px 2px rgba(16, 27, 26, .04), 0 2px 8px rgba(16, 27, 26, .04);
  --shadow-md: 0 2px 6px rgba(16, 27, 26, .05), 0 12px 28px -8px rgba(16, 27, 26, .10);
  --shadow-lg: 0 4px 10px rgba(16, 27, 26, .05), 0 28px 60px -18px rgba(16, 27, 26, .18);
  --shadow-glow: 0 18px 50px -20px rgba(23, 53, 47, .45);

  /* Motion */
  --ease-out:  cubic-bezier(.22, 1, .36, 1);
  --ease-soft: cubic-bezier(.32, .72, 0, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --dur-fast: 180ms;
  --dur:      420ms;
  --dur-slow: 760ms;

  /* Layout */
  --wrap: 1200px;
  --wrap-narrow: 760px;
  --wrap-wide: 1440px;
  --gutter: clamp(1.15rem, 4vw, 3rem);
  --header-h: 76px;
  --banner-h: 0px;
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--banner-h) + 1.5rem);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.68;
  font-weight: 400;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
}

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

/* Grid and flex children default to min-width:auto, which lets a long
   unbreakable string (an email address, a URL) widen its track. */
.grid > *, .split > *, .contact-grid > *, .hero-grid > *, .process-grid > * { min-width: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 3px;
  border-radius: 4px;
}
::selection { background: var(--sage-soft); color: var(--forest-lo); }

/* --------------------------------------------------------------------------
   3. Bilingual visibility (EN / TH)
   Only the inactive language is hidden, so the active element keeps whatever
   display value the component stylesheet gave it.
   -------------------------------------------------------------------------- */
html[data-lang="en"] :is([lang="th"]) { display: none !important; }
html[data-lang="th"] :is([lang="en"]) { display: none !important; }

:lang(th) {
  font-family: var(--font-th-body);
  line-height: 1.9;
  letter-spacing: 0;
}
h1:lang(th), h2:lang(th), h3:lang(th), h4:lang(th),
.display:lang(th), .h1:lang(th), .h2:lang(th), .h3:lang(th), .h4:lang(th) {
  font-family: var(--font-th-display);
  line-height: 1.42;
  font-weight: 600;
  letter-spacing: 0;
}

/* Thai sets wider and taller than Latin at the same point size, and the
   display sizes tuned for Fraunces overwhelm a Thai headline. */
h1:lang(th), .h1:lang(th), .display:lang(th), .hero-title:lang(th) {
  font-size: clamp(1.95rem, 1.32rem + 2.5vw, 3.45rem);
}
h2:lang(th), .h2:lang(th) { font-size: clamp(1.6rem, 1.2rem + 1.7vw, 2.5rem); }
h3:lang(th), .h3:lang(th) { font-size: clamp(1.2rem, 1.05rem + .6vw, 1.55rem); }
h4:lang(th), .h4:lang(th) { font-size: clamp(1.1rem, 1rem + .4vw, 1.3rem); }

.eyebrow:lang(th) { letter-spacing: .04em; font-size: var(--fs-sm); }

/* Language crossfade */
.lang-swapping [lang="en"], .lang-swapping [lang="th"] {
  animation: langIn var(--dur) var(--ease-out) both;
}
@keyframes langIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   4. Typography
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, .display, .h1, .h2, .h3, .h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.028em;
  text-wrap: balance;
  font-variation-settings: "SOFT" 0, "WONK" 0, "opsz" 40;
  color: var(--forest);
}

.display, h1, .h1 { font-size: var(--fs-3xl); line-height: 1.02; letter-spacing: -0.035em; }
h2, .h2 { font-size: var(--fs-2xl); line-height: 1.06; }
h3, .h3 { font-size: var(--fs-xl);  line-height: 1.14; letter-spacing: -0.022em; }
h4, .h4 { font-size: var(--fs-lg);  line-height: 1.22; letter-spacing: -0.015em; }

p { text-wrap: pretty; }

.lead {
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: -0.012em;
}
.lead:lang(th) { line-height: 1.85; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .6em;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--clay);
  font-family: var(--font-body);
}
.eyebrow::before {
  content: "";
  width: 1.9em;
  height: 1px;
  background: currentColor;
  opacity: .5;
  transform-origin: left;
  animation: ruleGrow 1s var(--ease-out) both;
}
@keyframes ruleGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.eyebrow--center::after {
  content: "";
  width: 1.9em; height: 1px; background: currentColor; opacity: .5;
}

.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.serif-italic { font-family: var(--font-display); font-style: italic; }

/* An accent word inside a heading, with a hand-drawn underline */
/* The underline is painted as a background rather than a pseudo-element so
   that it survives the phrase wrapping onto a second line. */
.mark {
  font-style: italic;
  color: var(--clay);
  background-image: linear-gradient(rgba(189, 108, 76, .20), rgba(189, 108, 76, .20));
  background-repeat: no-repeat;
  background-position: 0 92%;
  background-size: 0% .30em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-size 900ms var(--ease-out) 260ms;
}
.is-visible .mark,
.is-typed .mark,
.mark.is-visible { background-size: 100% .30em; }
.tone-dark .mark { color: var(--clay-soft); background-image: linear-gradient(rgba(207, 159, 73, .30), rgba(207, 159, 73, .30)); }

.mark:lang(th) {
  font-style: normal;
  background-image: none;
  text-decoration: underline;
  text-decoration-color: rgba(189, 108, 76, .38);
  text-decoration-thickness: .1em;
  text-underline-offset: .22em;
}
.tone-dark .mark:lang(th) { text-decoration-color: rgba(207, 159, 73, .5); }

/* --------------------------------------------------------------------------
   5. Layout primitives
   -------------------------------------------------------------------------- */
.wrap {
  width: min(var(--wrap), 100% - var(--gutter) * 2);
  margin-inline: auto;
}
.wrap--narrow { width: min(var(--wrap-narrow), 100% - var(--gutter) * 2); }
.wrap--wide   { width: min(var(--wrap-wide),   100% - var(--gutter) * 2); }

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: clamp(3rem, 1.8rem + 5vw, 5.5rem); }
.section--flush-top { padding-top: 0; }

.section-head { max-width: 62ch; }
.section-head--center { margin-inline: auto; text-align: center; }
.section-head > * + * { margin-top: var(--sp-4); }
.section-head .lead { margin-top: var(--sp-5); }

.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-6); }

.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }

.split {
  display: grid;
  gap: clamp(2.5rem, 1rem + 6vw, 5.5rem);
  align-items: center;
}
@media (min-width: 900px) {
  .split { grid-template-columns: 1fr 1fr; }
  .split--media-first > :first-child { order: -1; }
  .split--60-40 { grid-template-columns: 1.35fr 1fr; }
  .split--40-60 { grid-template-columns: 1fr 1.35fr; }
}

.flow-tight > * + * { margin-top: var(--sp-3); }

/* Tonal section surfaces */
.tone-sand   { background: var(--sand); }
.tone-mist   { background: var(--sage-mist); }
.tone-paper  { background: var(--paper); }
.tone-dark   { background: var(--forest); color: var(--text-invert); }
.tone-dark h1, .tone-dark h2, .tone-dark h3, .tone-dark h4,
.tone-dark .h1, .tone-dark .h2, .tone-dark .h3, .tone-dark .h4 { color: var(--text-invert); }
.tone-dark .lead, .tone-dark .muted { color: var(--text-invert-muted); }
.tone-dark .eyebrow { color: var(--clay-soft); }

/* Soft curved top/bottom edges between tonal bands */
.edge-top    { border-radius: var(--r-xl) var(--r-xl) 0 0; }
.edge-bottom { border-radius: 0 0 var(--r-xl) var(--r-xl); }
.edge-all    { border-radius: var(--r-xl); }

/* --------------------------------------------------------------------------
   6. Decorative texture
   -------------------------------------------------------------------------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: .035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  opacity: .5;
  will-change: transform;
}

/* --------------------------------------------------------------------------
   7. Accessibility helpers
   -------------------------------------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; top: 0; left: 50%;
  transform: translate(-50%, -140%);
  z-index: 10000;
  background: var(--forest); color: var(--text-invert);
  padding: .8rem 1.4rem; border-radius: 0 0 var(--r-md) var(--r-md);
  font-size: var(--fs-sm); font-weight: 600;
  transition: transform var(--dur) var(--ease-out);
}
.skip-link:focus { transform: translate(-50%, 0); }

/* --------------------------------------------------------------------------
   8. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .mark { background-size: 100% .30em !important; }
}
