/* ============================================
   Dhamnamthai Foundation — Design System
   ============================================ */

:root {
  /* Palette — editorial warm */
  --ink: #1a1410;
  --ink-2: #3a2e25;
  --ink-3: #6b5d52;
  --ink-4: #9a8e82;
  --paper: #f7f3ec;
  --paper-2: #efe9dc;
  --cream: #ede4d3;
  --hairline: rgba(26, 20, 16, 0.12);
  --hairline-2: rgba(26, 20, 16, 0.06);
  --surface: #ffffff;

  --gold: #b78b3e;
  --gold-2: #8e6a26;
  --gold-soft: rgba(183, 139, 62, 0.12);

  --forest: #2d4a3e;
  --forest-2: #1f342b;
  --clay: #c25a3a;
  --sky: #4f7da0;

  /* Type */
  --font-sans: "IBM Plex Sans Thai", "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-serif: "IBM Plex Serif", Georgia, serif;

  /* Scale */
  --r-pill: 9999px;
  --r-md: 4px;
  --r-card: 2px;

  --shadow-sm: 0 1px 2px rgba(26, 20, 16, 0.04), 0 4px 14px rgba(26, 20, 16, 0.06);
  --shadow-md: 0 8px 28px rgba(26, 20, 16, 0.10);
  --shadow-lg: 0 24px 60px rgba(26, 20, 16, 0.16);

  --t-fast: 180ms cubic-bezier(0.2, 0.7, 0.3, 1);
  --t-med: 320ms cubic-bezier(0.2, 0.7, 0.3, 1);
  --t-slow: 560ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

[data-theme="dark"] {
  --ink: #f4ece0;
  --ink-2: #d6cdbe;
  --ink-3: #a89e8e;
  --ink-4: #6e6558;
  --paper: #15110d;
  --paper-2: #1c1814;
  --cream: #23201b;
  --hairline: rgba(244, 236, 224, 0.14);
  --hairline-2: rgba(244, 236, 224, 0.06);
  --surface: #1a1612;
  --gold: #d4a14a;
  --gold-2: #b78b3e;
  --gold-soft: rgba(212, 161, 74, 0.16);
  --forest: #5a8d76;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  text-wrap: pretty;
  letter-spacing: 0.005em;
}

img { display: block; max-width: 100%; }

::selection { background: var(--gold); color: var(--paper); }

/* ============================================
   Typography utilities
   ============================================ */

.label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-2);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.display {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.02;
  text-wrap: balance;
}

.serif-display {
  font-family: var(--font-serif);
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.018em;
  line-height: 1.08;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.005em;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: var(--ink-2); }

.btn-gold {
  background: var(--gold);
  color: #1a1410;
}
.btn-gold:hover { background: var(--gold-2); color: var(--paper); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--hairline);
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.btn-link {
  height: auto;
  padding: 4px 0;
  background: transparent;
  color: var(--ink);
  border: none;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
}

.btn-sm { height: 36px; padding: 0 16px; font-size: 13px; }
.btn-lg { height: 54px; padding: 0 28px; font-size: 15px; }

/* ============================================
   Layout helpers
   ============================================ */

.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 48px;
}

.section { padding: 120px 0; }
.section-sm { padding: 72px 0; }

.hairline { background: var(--hairline); height: 1px; border: none; }

/* ============================================
   Editorial grid
   ============================================ */

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.grid-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; }

/* ============================================
   Cards
   ============================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  transition: transform var(--t-med), box-shadow var(--t-med), border-color var(--t-med);
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--hairline);
}

/* ============================================
   Photo treatments
   ============================================ */

.photo {
  background: var(--cream);
  overflow: hidden;
  position: relative;
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 800ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

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

.photo-placeholder {
  background:
    repeating-linear-gradient(
      45deg,
      var(--cream),
      var(--cream) 8px,
      var(--paper-2) 8px,
      var(--paper-2) 16px
    );
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ============================================
   Scroll-reveal
   ============================================ */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 700ms cubic-bezier(0.2, 0.7, 0.3, 1), transform 700ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.reveal.in {
  opacity: 1;
  transform: none;
}

/* ============================================
   Marquee
   ============================================ */

@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.marquee {
  display: flex;
  width: max-content;
  animation: marquee 40s linear infinite;
}

/* ============================================
   Nav
   ============================================ */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 243, 236, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.nav.scrolled { border-color: var(--hairline); }

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 32px;
}

.nav-links {
  display: flex;
  gap: 0;
  align-items: center;
}

.nav-link {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--t-fast);
  position: relative;
}

.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); }
.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: -22px;
  left: 16px;
  right: 16px;
  height: 2px;
  background: var(--gold);
}

/* ============================================
   Footer
   ============================================ */

.footer {
  background: var(--ink);
  color: var(--paper);
  padding: 96px 0 36px;
}

.footer .label { color: rgba(247, 243, 236, 0.5); }

/* ============================================
   Forms
   ============================================ */

.field {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  border-radius: var(--r-md);
  transition: border-color var(--t-fast);
}

.field:focus { outline: none; border-color: var(--ink); }

.field-lg { height: 56px; font-size: 17px; }

/* ============================================
   Tag
   ============================================ */

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  background: var(--gold-soft);
  color: var(--gold-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 2px;
}

.tag-forest { background: rgba(45, 74, 62, 0.1); color: var(--forest); }
.tag-clay { background: rgba(194, 90, 58, 0.1); color: var(--clay); }
.tag-sky { background: rgba(79, 125, 160, 0.1); color: var(--sky); }
.tag-ink { background: rgba(26, 20, 16, 0.08); color: var(--ink-2); }

/* ============================================
   Chatbot
   ============================================ */

.chatbot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--t-fast), background var(--t-fast);
}

.chatbot-fab:hover { transform: scale(1.06); background: var(--gold); color: var(--ink); }

.chatbot-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 540px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--hairline);
  transform-origin: bottom right;
  animation: chatbot-in 280ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes chatbot-in {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to { opacity: 1; transform: none; }
}

/* ============================================
   Mobile (≤ 720px)
   ============================================ */

@media (max-width: 720px) {
  .container { padding: 0 20px; }
  .section { padding: 64px 0; }
  .section-sm { padding: 40px 0; }
  .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 20px; }
  .grid-12 { grid-template-columns: 1fr; gap: 20px; }
  .nav-inner { padding: 0 16px; height: 60px; }
  .nav-links { display: none; }
  .nav-volunteer-btn { display: none !important; }
  .footer-grid { grid-template-columns: 1fr !important; gap: 32px !important; }
  .chatbot-panel { width: calc(100vw - 32px); right: 16px; bottom: 88px; height: 70vh; }
  .chatbot-fab { right: 16px; bottom: 16px; width: 52px; height: 52px; }
}

/* Density modifier */
[data-density="comfortable"] .section { padding: 160px 0; }
[data-density="comfortable"] .grid-3 { gap: 48px; }
