/* =====================================================================
   GROW-CODE — Carbon-inspired design system (earth-tone theme)
   Built on IBM Carbon Design principles: IBM Plex type, the 2x grid,
   spacing + type tokens, sharp/rectangular interactives, 2px focus.
   Re-themed with a warm cocoa / green / sand earth palette.
   ===================================================================== */

/* ---------------- design tokens ---------------- */
:root {
  /* spacing scale (Carbon 2x) */
  --sp-01: 0.125rem; --sp-02: 0.25rem; --sp-03: 0.5rem;  --sp-04: 0.75rem;
  --sp-05: 1rem;     --sp-06: 1.5rem;  --sp-07: 2rem;    --sp-08: 2.5rem;
  --sp-09: 3rem;     --sp-10: 4rem;    --sp-11: 5rem;    --sp-12: 6rem;
  --sp-13: 10rem;

  /* motion (Carbon easings + durations) */
  --ease-standard: cubic-bezier(0.2, 0, 0.38, 0.9);
  --ease-entrance: cubic-bezier(0, 0, 0.38, 0.9);
  --ease-exit:     cubic-bezier(0.2, 0, 1, 0.9);
  --dur-fast: 110ms; --dur-mod: 240ms; --dur-slow: 400ms;

  /* type */
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* container */
  --maxw: 84rem; /* 1344px */
  --radius: 0;   /* Carbon is rectangular */
}

/* ---------- LIGHT (default) earth theme ---------- */
:root, :root[data-theme="light"] {
  --bg:            #FBF7F0;
  --layer-01:      #FFFFFF;
  --layer-02:      #F4ECDE;
  --layer-03:      #EDE3D1;
  --layer-hover:   #EFE6D4;
  --layer-active:  #E6D9C2;
  --border-subtle: #E6DAC6;
  --border-strong: #C9B896;
  --text-primary:  #2A2019;
  --text-secondary:#6E5F4E;
  --text-helper:   #8A7B66;
  --text-placeholder:#A99A83;
  --text-on-color: #FBF7F0;
  --text-on-brand: #FBF7F0;

  --brand:         #6B4A2B; /* cocoa */
  --brand-hover:   #573B22;
  --brand-active:  #45301C;
  --accent:        #C4703D; /* terracotta CTA */
  --accent-hover:  #AC5F30;
  --accent-active: #954F27;
  --link:          #7A5230;
  --link-hover:    #573B22;

  --forest:        #3B4A2C; /* deep green */
  --fern:          #4E6B3A;
  --sage:          #7C9066;
  --khaki:         #8C7B4C; /* the brand gold blocks */
  --khaki-deep:    #74653C;

  --success:       #4E6B3A;
  --error:         #9E3B2E;
  --warning:       #C0872B;
  --info:          #4E6B3A;
  --focus:         #6B4A2B;
  --overlay:       rgba(42, 32, 25, 0.55);
  --shadow-sm: 0 1px 2px rgba(42,32,25,.08), 0 1px 3px rgba(42,32,25,.06);
  --shadow-md: 0 4px 12px rgba(42,32,25,.10), 0 2px 6px rgba(42,32,25,.06);
  --shadow-lg: 0 16px 40px rgba(42,32,25,.16);
  color-scheme: light;
}

/* ---------- DARK (espresso) earth theme ---------- */
:root[data-theme="dark"] {
  --bg:            #201812;
  --layer-01:      #2B211A;
  --layer-02:      #362A20;
  --layer-03:      #403327;
  --layer-hover:   #3B2E23;
  --layer-active:  #4A3B2C;
  --border-subtle: #44372A;
  --border-strong: #5E4C39;
  --text-primary:  #F3EADB;
  --text-secondary:#CBB99F;
  --text-helper:   #A9977E;
  --text-placeholder:#8B7A64;
  --text-on-color: #201812;
  --text-on-brand: #FBF7F0;

  --brand:         #CA9C6C;
  --brand-hover:   #D9AE80;
  --brand-active:  #E4BE93;
  --accent:        #D98A54;
  --accent-hover:  #E39A67;
  --accent-active: #ECA97A;
  --link:          #DDAE7C;
  --link-hover:    #ECC59A;

  --forest:        #7C9066;
  --fern:          #8CA672;
  --sage:          #9DB088;
  --khaki:         #B7A268;
  --khaki-deep:    #8C7B4C;

  --success:       #8CA672;
  --error:         #E0806F;
  --warning:       #E0AE5C;
  --info:          #9DB088;
  --focus:         #E4BE93;
  --overlay:       rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 46px rgba(0,0,0,.55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#201812; --layer-01:#2B211A; --layer-02:#362A20; --layer-03:#403327;
    --layer-hover:#3B2E23; --layer-active:#4A3B2C; --border-subtle:#44372A; --border-strong:#5E4C39;
    --text-primary:#F3EADB; --text-secondary:#CBB99F; --text-helper:#A9977E; --text-placeholder:#8B7A64;
    --text-on-color:#201812; --text-on-brand:#FBF7F0;
    --brand:#CA9C6C; --brand-hover:#D9AE80; --brand-active:#E4BE93;
    --accent:#D98A54; --accent-hover:#E39A67; --accent-active:#ECA97A;
    --link:#DDAE7C; --link-hover:#ECC59A;
    --forest:#7C9066; --fern:#8CA672; --sage:#9DB088; --khaki:#B7A268; --khaki-deep:#8C7B4C;
    --success:#8CA672; --error:#E0806F; --warning:#E0AE5C; --info:#9DB088; --focus:#E4BE93;
    --overlay:rgba(0,0,0,.6);
    --shadow-sm:0 1px 2px rgba(0,0,0,.4); --shadow-md:0 6px 16px rgba(0,0,0,.45); --shadow-lg:0 18px 46px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}

/* ---------------- reset ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem; line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { max-width: 100%; display: block; }
a { color: var(--link); text-decoration: none; transition: color var(--dur-fast) var(--ease-standard); }
a:hover { color: var(--link-hover); text-decoration: underline; }
h1,h2,h3,h4,h5,h6 { margin: 0; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0 0 var(--sp-05); }
hr { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--sp-07) 0; }
ul, ol { margin: 0 0 var(--sp-05); padding-left: 1.4em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------------- type scale ---------------- */
.t-display { font-family: var(--font-serif); font-size: clamp(2.6rem, 6vw, 4.4rem); line-height: 1.06; font-weight: 600; letter-spacing: -0.02em; }
.t-h1 { font-family: var(--font-serif); font-size: clamp(2rem, 4.2vw, 3rem); line-height: 1.12; }
.t-h2 { font-family: var(--font-serif); font-size: clamp(1.6rem, 3vw, 2.15rem); line-height: 1.18; }
.t-h3 { font-size: clamp(1.3rem, 2.2vw, 1.6rem); line-height: 1.25; }
.t-h4 { font-size: 1.2rem; line-height: 1.3; }
.t-lead { font-size: clamp(1.05rem, 1.6vw, 1.28rem); line-height: 1.55; color: var(--text-secondary); }
.t-body { font-size: 1rem; }
.t-small { font-size: 0.875rem; }
.t-label { font-size: 0.75rem; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-helper); font-weight: 600; }
.t-eyebrow { font-size: 0.8125rem; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 600; color: var(--brand); }
.text-secondary { color: var(--text-secondary); }
.serif { font-family: var(--font-serif); }

/* ---------------- layout / grid ---------------- */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--sp-06); }
.container-narrow { max-width: 48rem; }
.section { padding: var(--sp-11) 0; }
.section-sm { padding: var(--sp-09) 0; }
.grid { display: grid; gap: var(--sp-06); grid-template-columns: repeat(12, 1fr); }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; } .col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }
@media (max-width: 960px) {
  .col-3,.col-4,.col-5 { grid-column: span 6; }
  .col-6,.col-7,.col-8,.col-9 { grid-column: span 12; }
}
@media (max-width: 640px) { .grid > [class^="col-"] { grid-column: span 12; } }

.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-03); } .gap-3 { gap: var(--sp-04); } .gap-4 { gap: var(--sp-05); } .gap-6 { gap: var(--sp-06); }
.wrap { flex-wrap: wrap; }
.mt-0{margin-top:0}.mt-2{margin-top:var(--sp-03)}.mt-4{margin-top:var(--sp-05)}.mt-6{margin-top:var(--sp-07)}.mt-8{margin-top:var(--sp-09)}
.mb-0{margin-bottom:0}.mb-2{margin-bottom:var(--sp-03)}.mb-4{margin-bottom:var(--sp-05)}.mb-6{margin-bottom:var(--sp-07)}
.text-center { text-align: center; }

/* ---------------- buttons (Carbon: rectangular, icon-right) ---------------- */
.btn {
  --_bg: var(--brand); --_fg: var(--text-on-brand); --_bg-h: var(--brand-hover);
  display: inline-flex; align-items: center; justify-content: space-between; gap: var(--sp-05);
  min-height: 48px; padding: 12px 16px; max-width: 20rem;
  font-family: var(--font-sans); font-size: 1rem; font-weight: 500; line-height: 1.3;
  border: 2px solid transparent; border-radius: var(--radius); cursor: pointer;
  background: var(--_bg); color: var(--_fg);
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
  text-decoration: none;
}
.btn:hover { background: var(--_bg-h); color: var(--_fg); text-decoration: none; }
.btn:active { background: var(--brand-active); }
.btn svg { flex: none; }
.btn--accent { --_bg: var(--accent); --_bg-h: var(--accent-hover); --_fg:#fff; }
.btn--accent:active { background: var(--accent-active); }
.btn--secondary { --_bg: var(--forest); --_bg-h: #4a5c39; --_fg:#fff; }
.btn--tertiary {
  background: transparent; color: var(--brand); border-color: var(--brand);
}
.btn--tertiary:hover { background: var(--brand); color: var(--text-on-brand); }
.btn--ghost { background: transparent; color: var(--brand); }
.btn--ghost:hover { background: var(--layer-hover); color: var(--brand); }
.btn--sm { min-height: 40px; padding: 8px 14px; font-size: .9375rem; }
.btn--block { display: flex; width: 100%; max-width: none; }
.btn--danger { --_bg: var(--error); --_bg-h:#883225; --_fg:#fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------- form fields (Carbon style) ---------------- */
.field { margin-bottom: var(--sp-06); }
.field > label, .label { display: block; font-size: .75rem; color: var(--text-helper); margin-bottom: var(--sp-03); font-weight: 500; }
.input, .textarea, .select {
  width: 100%; font-family: var(--font-sans); font-size: 1rem; color: var(--text-primary);
  background: var(--layer-02); border: none; border-bottom: 1px solid var(--border-strong);
  border-radius: 0; padding: 12px 16px; min-height: 48px;
  transition: background var(--dur-fast), border-color var(--dur-fast), outline var(--dur-fast);
}
.textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-placeholder); }
.input:focus, .textarea:focus, .select:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--layer-02); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%); background-position: calc(100% - 20px) 20px, calc(100% - 14px) 20px; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
.helper { font-size: .75rem; color: var(--text-helper); margin-top: var(--sp-03); }
.field-error .input, .field-error .textarea { outline: 2px solid var(--error); outline-offset: -2px; }

/* ---------------- tags / pills ---------------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  font-size: .75rem; font-weight: 500; border-radius: 12px;
  background: var(--layer-03); color: var(--text-secondary); text-decoration: none;
}
.tag--brand { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.tag--accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-active); }
.tag--green { background: color-mix(in srgb, var(--fern) 18%, transparent); color: var(--fern); }
a.tag:hover { text-decoration: none; background: var(--layer-active); }

/* ---------------- tiles / cards ---------------- */
.tile {
  background: var(--layer-01); border: 1px solid var(--border-subtle);
  padding: var(--sp-07); transition: box-shadow var(--dur-mod) var(--ease-standard), transform var(--dur-mod) var(--ease-standard), border-color var(--dur-mod);
}
.tile--hover:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

/* ---------------- inline notification ---------------- */
.note {
  display: flex; gap: var(--sp-04); align-items: flex-start;
  padding: var(--sp-05); border-left: 3px solid var(--info);
  background: var(--layer-02); color: var(--text-primary); font-size: .9375rem; margin-bottom: var(--sp-05);
}
.note--success { border-left-color: var(--success); }
.note--error { border-left-color: var(--error); }
.note--warning { border-left-color: var(--warning); }
.note strong { display: block; }

/* ---------------- data table ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-subtle); background: var(--layer-01); }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { text-align: left; font-size: .75rem; letter-spacing: .02em; text-transform: uppercase; color: var(--text-helper); font-weight: 600; padding: 14px 16px; background: var(--layer-02); border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--layer-hover); }

/* ---------------- misc ---------------- */
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--brand); color: #fff; padding: 12px 16px; z-index: 1000; }
.skip-link:focus { left: 0; }
.badge-dot { display:inline-block; width:8px; height:8px; border-radius:50%; background: var(--success); }
.visually-hidden { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); border:0; }
.divider-accent { width: 64px; height: 4px; background: var(--khaki); border: 0; margin: var(--sp-05) 0; }
