/* ═══════════════════════════════════════════════════════════
   The Household Map — module interiors.
   Every module keeps its colours in its own tokens (--crd-*, --fin-*, …,
   and Kitchen uses base.css's --green-900/--cream/…). Here each module's
   tokens are re-pointed at one shared parchment-and-ink palette, so a
   module reskins without its own CSS changing. Token blocks sit on :root,
   so `html.theme-map` (one class more specific) wins; ATC's live on
   #module-atc, so those selectors carry the id too.
   Below the token blocks are the few hard-coded bits that needed a patch.
   ═══════════════════════════════════════════════════════════ */

html.theme-map {
  /* Shared interior palette (day) */
  --mp-page:       #ead8b1;
  --mp-card:       #f2e4c3;
  --mp-field:      #e4d0a4;
  --mp-line:       rgba(58, 35, 19, 0.20);
  --mp-line-2:     rgba(58, 35, 19, 0.32);
  --mp-ink:        #3a2313;
  --mp-dim:        #7b5d41;
  --mp-faint:      #a88d6c;
  --mp-accent:     #6b3a1c;   /* sepia: primary buttons, selected tabs */
  --mp-accent-2:   #4d2911;
  --mp-accent-soft:#e2c99a;
  --mp-on-accent:  #f6ead0;
  --mp-red:        #8b1e17;   /* oxblood: danger, overdue */
  --mp-red-soft:   #efd2bf;
  --mp-gold:       #a8761e;
  --mp-gold-soft:  #ecd7a6;
  --mp-green:      #556b2a;   /* olive ink: done, up */
  --mp-green-soft: #dfdcb0;
  --mp-blue:       #2f4f6b;   /* slate ink */
  --mp-rose:       #8a3b5a;
  --mp-shadow:     0 1px 2px rgba(60, 30, 8, 0.10), 0 4px 14px rgba(60, 30, 8, 0.12);

  --font-ui:      'EB Garamond', Georgia, serif;
  --font-display: 'IM Fell English', Georgia, serif;
  --font-mono:    'IM Fell English', Georgia, serif;

  /* Kitchen (base.css tokens) */
  --green-900: var(--mp-accent);
  --green-700: var(--mp-accent-2);
  --green-100: var(--mp-accent-soft);
  --gold:      var(--mp-gold);
  --gold-soft: var(--mp-gold-soft);
  --cream:     var(--mp-page);
  --surface:   var(--mp-card);
  --text-900:  var(--mp-ink);
  --text-500:  var(--mp-dim);
  --text-300:  var(--mp-faint);
  --border:    var(--mp-line);
  --red:       var(--mp-red);
  --red-soft:  var(--mp-red-soft);
  --yellow:    #d9b44a;
  --yellow-dark: #2a1d05;
  --shadow-card:   var(--mp-shadow);
  --shadow-raised: 0 4px 18px rgba(60, 30, 8, 0.18), 0 2px 6px rgba(60, 30, 8, 0.10);
  --shadow-dock:   0 -4px 20px rgba(60, 30, 8, 0.16);

  /* Cards */
  --crd-bg: var(--mp-page);  --crd-card: var(--mp-card);
  --crd-accent: var(--mp-accent);  --crd-accent-dark: var(--mp-accent-2);
  --crd-text: var(--mp-ink);  --crd-text-dim: var(--mp-dim);
  --crd-danger: var(--mp-red);  --crd-shadow: var(--mp-shadow);
  --crd-dashed-border: var(--mp-line-2);

  /* Household Budget */
  --fin-bg: var(--mp-page);  --fin-card: var(--mp-card);
  --fin-coral: var(--mp-red);  --fin-coral-dark: #6e160f;
  --fin-navy: var(--mp-ink);  --fin-text: var(--mp-ink);  --fin-text-dim: var(--mp-dim);
  --fin-shadow: var(--mp-shadow);  --fin-dock-bg: rgba(234, 216, 177, 0.94);
  --fin-dashed-border: var(--mp-line-2);

  /* Medicine Cabinet */
  --med-bg: var(--mp-page);  --med-card: var(--mp-card);
  --med-ink: var(--mp-ink);  --med-dim: var(--mp-dim);  --med-line: var(--mp-line);
  --med-teal: var(--mp-green);  --med-teal-dark: #3f5120;  --med-teal-soft: var(--mp-green-soft);
  --med-flame: var(--mp-gold);  --med-flame-soft: var(--mp-gold-soft);
  --med-shadow: var(--mp-shadow);
  --med-font-mono: 'IM Fell English', Georgia, serif;

  /* Next Move */
  --nxm-bg: var(--mp-page);  --nxm-card: var(--mp-card);
  --nxm-ink: var(--mp-ink);  --nxm-dim: var(--mp-dim);  --nxm-line: var(--mp-line);
  --nxm-field: var(--mp-field);
  --nxm-brick: var(--mp-accent);  --nxm-brick-dark: var(--mp-accent-2);  --nxm-brick-soft: var(--mp-accent-soft);
  --nxm-up: var(--mp-green);  --nxm-down: var(--mp-red);  --nxm-gap: var(--mp-gold-soft);
  --nxm-s0: var(--mp-dim);  --nxm-s1: var(--mp-red);  --nxm-s2: var(--mp-blue);
  --nxm-s3: var(--mp-green);  --nxm-s4: var(--mp-gold);
  --nxm-shadow: var(--mp-shadow);

  /* Itineraries (was a dark-only palette) */
  --itn-bg: var(--mp-page);  --itn-card: var(--mp-card);  --itn-line: var(--mp-line);
  --itn-text: var(--mp-ink);  --itn-dim: var(--mp-dim);
  --itn-joint: var(--mp-gold);  --itn-dan: var(--mp-blue);  --itn-sarah: var(--mp-rose);
  --itn-red: var(--mp-red);

  /* Utility Room */
  --util-bg: var(--mp-page);  --util-card: var(--mp-card);
  --util-steel: var(--mp-ink);  --util-steel-dim: var(--mp-dim);
  --util-accent: var(--mp-gold);  --util-accent-dark: #85590f;
  --util-shadow: var(--mp-shadow);

  /* Notice Board */
  --notice-bg: var(--mp-page);
  --notice-frame-lt: #b98b55;  --notice-frame: #8e6436;  --notice-frame-dk: #5e3d1d;
  --notice-blue: var(--mp-blue);  --notice-red: var(--mp-red);  --notice-green: var(--mp-green);
  --notice-black: var(--mp-ink);  --notice-orange: var(--mp-gold);
  --notice-ink: var(--mp-ink);  --notice-ink-dim: var(--mp-dim);
  --notice-grid: rgba(58, 35, 19, 0.05);
  --notice-shadow: var(--mp-shadow);
  --notice-font-marker: 'IM Fell English', Georgia, serif;
  --notice-alert-bg: var(--mp-page);  --notice-alert-card: var(--mp-card);
  --notice-alert-red: var(--mp-red);  --notice-alert-red-dark: #6e160f;
  --notice-alert-amber: var(--mp-gold);
  --notice-alert-text: var(--mp-ink);  --notice-alert-text-dim: var(--mp-dim);
  --notice-alert-border: var(--mp-line);
}

/* Lamplight: the same palette, by candle. */
html.theme-map.map-night {
  --mp-page:       #33251a;
  --mp-card:       #3e2e20;
  --mp-field:      #2a1e14;
  --mp-line:       rgba(239, 205, 133, 0.16);
  --mp-line-2:     rgba(239, 205, 133, 0.28);
  --mp-ink:        #efcd85;
  --mp-dim:        #bf9e68;
  --mp-faint:      #8a7150;
  --mp-accent:     #d9a95a;
  --mp-accent-2:   #c08f40;
  --mp-accent-soft:#4a3722;
  --mp-on-accent:  #241810;
  --mp-red:        #e58a6a;
  --mp-red-soft:   #4a2a20;
  --mp-gold:       #e8bd62;
  --mp-gold-soft:  #4a3a1e;
  --mp-green:      #b5c97f;
  --mp-green-soft: #39391f;
  --mp-blue:       #9dbbd8;
  --mp-rose:       #e0a0b8;
  --mp-shadow:     0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.4);
  --fin-dock-bg:   rgba(51, 37, 26, 0.94);
  --yellow-dark:   #241810;
}

/* Lining figures: old-style numerals make money columns hard to scan. */
html.theme-map body {
  font-variant-numeric: lining-nums;
  color: var(--mp-ink);
}

/* ── ATC Tower: the radar becomes an inked chart ─────────── */
html.theme-map #module-atc,
html.theme-map .atc-modal-backdrop,
html.theme-map .atc-modal-backdrop[data-theme] {
  --atc-bg: #e8d5ad; --atc-panel: #e0c99a; --atc-line: rgba(58, 35, 19, 0.28);
  --atc-text: #3a2313; --atc-dim: #7b5d41; --atc-accent: #6b3a1c;
  --atc-blip: #3a2313; --atc-ground: #8f7350; --atc-mil: #2f4f6b;
  --atc-emerg: #8b1e17; --atc-sweep: #a8761e; --atc-rwy: #3a2313;
  --atc-font: 'IM Fell English', Georgia, serif;
}
html.theme-map.map-night #module-atc,
html.theme-map.map-night .atc-modal-backdrop,
html.theme-map.map-night .atc-modal-backdrop[data-theme] {
  --atc-bg: #2b1f15; --atc-panel: #33251a; --atc-line: rgba(239, 205, 133, 0.22);
  --atc-text: #efcd85; --atc-dim: #bf9e68; --atc-accent: #f2d69a;
  --atc-blip: #f2d69a; --atc-ground: #8a7150; --atc-mil: #9dbbd8;
  --atc-emerg: #e58a6a; --atc-sweep: #e8bd62; --atc-rwy: #efcd85;
}
html.theme-map:has(#module-atc:not([style*="none"])),
html.theme-map body:has(#module-atc:not([style*="none"])),
html.theme-map .app-container:has(#module-atc:not([style*="none"])) { background: var(--atc-bg, #e8d5ad); }
html.theme-map #module-atc .mod-header { margin: 0; border-radius: 0; }

/* ── Night-safe accents ───────────────────────────────────────
   Several modules hard-code white text on their accent buttons, so by
   lamplight the accent is a mid amber (not pale gold) to keep it legible. */
html.theme-map { --mp-seal: #8b1e17; --mp-glass: rgba(234, 216, 177, 0.94); }
html.theme-map.map-night {
  --mp-accent: #b8843a;
  --mp-accent-2: #a0702c;
  --mp-seal: #9c3524;
  --mp-glass: rgba(51, 37, 26, 0.94);
  --itn-joint: var(--mp-accent);
  --util-accent: var(--mp-accent);
}
html.theme-map { --fin-coral: var(--mp-seal); }

/* ── Kitchen: sticky bars, diary and receipt sheets ──────── */
html.theme-map :is(.view-tabs, .form-dock, .shop-header, .shop-dock) { background: var(--mp-glass); }
html.theme-map :is(.diary-card, .diary-card--today, .diary-card--past, .history-sheet) { background-color: var(--mp-card); }

/* ── Utility Room ────────────────────────────────────────── */
html.theme-map .util-form-dock { background: var(--mp-glass); }

/* ── Notice Board: the whiteboard becomes a sheet of parchment
   pinned in a wooden frame. ── */
html.theme-map #module-notice {
  background-image: var(--map-stains), radial-gradient(circle, var(--notice-grid) 1px, transparent 1.4px);
  background-size: cover, 18px 18px;
}
html.theme-map .notice-tab-btn { background: var(--mp-card); }
html.theme-map .notice-tab-btn--active { background: var(--mp-ink); color: var(--mp-page); }
html.theme-map #notice-add-btn { background: var(--mp-accent); color: #fff8e8; box-shadow: var(--mp-shadow); }

/* ── Cards: each card is a sealed promissory note, not plastic.
   The face's colour is an inline style set per network, hence !important. */
html.theme-map .crd-card-face {
  position: relative;
  background: var(--mp-card) var(--map-grain) !important;
  border: 1.5px solid var(--mp-ink);
  border-radius: 4px;
  box-shadow: inset 0 0 0 5px var(--mp-card), inset 0 0 0 6px var(--mp-line-2), var(--mp-shadow);
}
html.theme-map .crd-card-face * { color: var(--mp-ink); }
html.theme-map .crd-card-face :is(.crd-card-recon-date, .crd-card-tap-hint, .crd-card-network) { color: var(--mp-dim); }
html.theme-map .crd-card-name { font-family: var(--map-font-sc); font-weight: 400; }
html.theme-map .crd-card-face::after {
  content: '';
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #b5433a 0%, #8b1e17 55%, #5e120c 100%);
  box-shadow: 0 0 0 3px rgba(139, 30, 23, 0.28), 0 2px 4px rgba(60, 20, 8, 0.35);
}
html.theme-map .crd-card-edit-date { background: var(--mp-line); color: var(--mp-ink); }

/* ── Budget: category colours (stored per category) aged to sepia ── */
html.theme-map :is(.fin-line-icon, .fin-cat-dot, .fin-cat-mgr-dot) { filter: sepia(0.75) saturate(0.85) brightness(0.92); }

/* Form controls don't inherit the page font by default, so names inside
   buttons/inputs stayed modern. :where() keeps this at zero specificity:
   it only beats the browser default, never a font a module chose. */
:where(html.theme-map) :where(button, input, select, textarea) { font-family: inherit; }
