/* ============================================================
   Trash Tribes — design tokens
   ------------------------------------------------------------
   Parchment and ink, with the Ordnance-Survey-ish warmth the
   brand has carried since the first concept boards. Segment
   colours are the CONFIRMED hexes from the colour states sheet
   and must not be re-tuned for contrast here — the map is the
   product, and a line's colour is data, not decoration.
   ============================================================ */

:root {
  /* surfaces */
  --paper:       #F3EEE1;
  --paper-deep:  #E8E1CC;
  --paper-warm:  #FBF8F0;
  --card:        #FFFDF8;
  --ink:         #24231D;
  --ink-soft:    #57544A;
  --ink-faint:   #857F71;
  --line:        #DBD3BC;
  --line-soft:   #EBE4D2;

  /* brand */
  --green:       #2D6A4F;
  --green-deep:  #1F4D38;
  --moss:        #40916C;
  --gold:        #B08A2E;
  --gold-soft:   #C9973B;

  /* confirmed segment states — do not re-tune */
  --seg-recent:     #63F5A8;
  --seg-historical: #257E6A;
  --seg-risk:       #D6425E;

  /* semantic */
  --ok:      #2D6A4F;
  --warn:    #B08A2E;
  --danger:  #B5324A;

  /* type */
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* geometry */
  --r-sm: 5px;
  --r-md: 9px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(36,35,29,.06), 0 2px 6px rgba(36,35,29,.05);
  --shadow-md: 0 4px 14px rgba(36,35,29,.10), 0 12px 32px rgba(36,35,29,.08);
  --shadow-lg: 0 10px 30px rgba(36,35,29,.16), 0 30px 70px rgba(36,35,29,.12);

  --head-h: 62px;
}

/* App chrome follows the dark map style so the two don't fight. */
body.theme-dark {
  --paper:      #1A1E19;
  --paper-deep: #14170F;
  --paper-warm: #222720;
  --card:       #232821;
  --ink:        #E9E4D6;
  --ink-soft:   #A9A395;
  --ink-faint:  #7C7768;
  --line:       #39402F;
  --line-soft:  #2C3226;
  --green:      #4FA47B;
  --moss:       #63BE93;
  --gold:       #D0A44A;
  --gold-soft:  #E0B968;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- shared primitives ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 26px; }
.narrow { max-width: 730px; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: .875rem; }
.tiny  { font-size: .78rem; line-height: 1.5; }
.ui    { font-family: var(--sans); }
.center { text-align: center; }
.stack > * + * { margin-top: 10px; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.18; }
h1 { font-size: clamp(2.15rem, 5.2vw, 3.5rem); letter-spacing: -.015em; }
h2 { font-size: clamp(1.55rem, 3.1vw, 2.2rem); letter-spacing: -.01em; }
h3 { font-size: 1.1rem; }
a  { color: var(--green); }

.eyebrow {
  font-family: var(--sans); font-size: .74rem; font-weight: 700;
  letter-spacing: .19em; text-transform: uppercase;
  color: var(--green); margin-bottom: 13px;
}
.eyebrow-gold { color: var(--gold-soft); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--sans); font-size: .93rem; font-weight: 500;
  cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--r-sm);
  border: 1.5px solid var(--green); background: transparent; color: var(--green);
  transition: background .15s, color .15s, border-color .15s, transform .08s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-solid  { background: var(--green); color: var(--paper-warm); }
.btn-solid:hover:not(:disabled) { background: var(--green-deep); border-color: var(--green-deep); }
.btn-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--green) 10%, transparent); }
.btn-quiet {
  border-color: var(--line); color: var(--ink-soft); background: var(--card);
}
.btn-quiet:hover:not(:disabled) { border-color: var(--ink-faint); color: var(--ink); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn-lg  { padding: 13px 26px; font-size: 1rem; }
.btn-sm  { padding: 7px 13px; font-size: .84rem; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: .42; cursor: not-allowed; }

.linkbtn {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: var(--sans); font-size: .85rem; color: var(--green);
  text-decoration: underline; text-underline-offset: 2px;
}
.linkbtn:hover { color: var(--green-deep); }
:focus-visible { outline: 3px solid var(--gold-soft); outline-offset: 2px; border-radius: 3px; }

/* ---------- form fields ---------- */
.fld { display: block; margin-top: 14px; }
.fld-label {
  display: block; font-family: var(--sans); font-size: .8rem; font-weight: 600;
  letter-spacing: .02em; color: var(--ink-soft); margin-bottom: 5px;
}
.fld input[type=text], .fld input[type=email], .fld input[type=password],
.fld input[type=number], .fld input[type=date], .fld select, .fld textarea {
  width: 100%; font-family: var(--sans); font-size: .95rem;
  padding: 9px 11px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink);
}
.fld textarea { resize: vertical; min-height: 62px; line-height: 1.5; }
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 15%, transparent);
}
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fld-hint { font-family: var(--sans); font-size: .76rem; color: var(--ink-faint); margin-top: 5px; }
.fld-error { font-family: var(--sans); font-size: .8rem; color: var(--danger); margin-top: 6px; }

/* ---------- chips + swatches ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--sans); font-size: .72rem; font-weight: 600;
  letter-spacing: .04em; padding: 3px 10px; border-radius: 999px;
  border: 1.5px solid var(--line); color: var(--ink-soft); background: var(--card);
}
.chip-recent     { background: var(--seg-recent); border-color: var(--seg-recent); color: #0E3626; }
.chip-historical { background: var(--seg-historical); border-color: var(--seg-historical); color: #EAF6F1; }
.chip-risk       { background: var(--seg-risk); border-color: var(--seg-risk); color: #fff; }
.chip-none       { background: transparent; }
.chip-provenance { background: transparent; border-style: dashed; color: var(--ink-faint); }

.swatch { width: 26px; height: 5px; border-radius: 3px; display: inline-block; flex: none; }
.sw-recent { background: var(--seg-recent); }
.sw-historical { background: var(--seg-historical); }
.sw-risk { background: var(--seg-risk); }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--r-md); padding: 18px 20px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(14px);
  background: var(--ink); color: var(--paper-warm);
  font-family: var(--sans); font-size: .88rem;
  padding: 11px 20px; border-radius: 999px; box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 400; max-width: min(560px, calc(100vw - 40px)); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { background: var(--danger); }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 300;
  background: color-mix(in srgb, var(--ink) 55%, transparent);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 22px;
  overflow-y: auto;
}
.overlay.hidden { display: none; }
.sheet {
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; padding: 26px 28px;
  max-height: calc(100vh - 44px); overflow-y: auto;
  border: 1.5px solid var(--line);
}
.sheet-wide { max-width: 620px; }
.sheet h2 { margin-bottom: 6px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 22px; }
.sheet-actions .btn { flex: 1; }

/* ---------- brand mark ---------- */
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green); color: var(--paper-warm);
  border: 2px solid var(--gold); font-family: var(--serif);
  font-weight: 700; font-size: 1.02rem; letter-spacing: .5px;
}
.brand-mark.lg { width: 56px; height: 56px; font-size: 1.5rem; }
.brand-name { font-weight: 700; letter-spacing: .2px; font-size: 1.02rem; }
