/* ═══════════════════════════════════════════════════════════
   The Household Map — theme styles.
   Every rule is scoped under html.theme-map (set by themes/theme.js),
   so this file is inert in OG. Markup it styles that isn't in the
   shell's HTML (cartouche, map SVG, notes, veil) is created by map.js.
   ═══════════════════════════════════════════════════════════ */

html.theme-map {
  --map-paper:      #ead8b1;
  --map-paper-2:    #e2cb9b;
  --map-paper-deep: #c9a66a;
  --map-burn:       rgba(92, 50, 14, 0.42);
  --map-ink:        #3a2313;
  --map-ink-soft:   rgba(58, 35, 19, 0.68);
  --map-ink-faint:  rgba(58, 35, 19, 0.22);
  --map-wash:       rgba(120, 66, 20, 0.13);
  --map-red:        #7a1f1a;
  --map-glow:       none;
  --map-font-title: 'UnifrakturMaguntia', 'IM Fell English SC', Georgia, serif;
  --map-font-sc:    'IM Fell English SC', Georgia, serif;
  --map-font:       'IM Fell English', Georgia, serif;
  --map-draw:       1.1s;
  --map-stagger:    0.028s;
  /* Paper grain + faint water stains, as a tiny inline SVG. */
  --map-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .22 0 0 0 0 .09 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --map-stains: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='700' height='700'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.008' numOctaves='3' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .27 0 0 0 0 .08 0 0 0 .55 -.18'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
}

/* Lamplight (after dark, set by map.js): the parchment dims and the ink
   takes on a faint gold glow. */
html.theme-map.map-night {
  --map-paper:      #34261a;
  --map-paper-2:    #2b1f15;
  --map-paper-deep: #1d140c;
  --map-burn:       rgba(8, 4, 1, 0.7);
  --map-ink:        #efcd85;
  --map-ink-soft:   rgba(239, 205, 133, 0.72);
  --map-ink-faint:  rgba(239, 205, 133, 0.22);
  --map-wash:       rgba(239, 205, 133, 0.10);
  --map-red:        #e58a6a;
  --map-glow:       0 0 6px rgba(240, 185, 80, 0.55);
}

/* ── Page ─────────────────────────────────────────────────── */
html.theme-map body,
html.theme-map body.home-active {
  background-color: var(--map-paper);
  background-image:
    radial-gradient(ellipse 120% 90% at 50% 45%, transparent 58%, var(--map-burn) 100%),
    var(--map-stains),
    var(--map-grain);
  background-repeat: no-repeat, no-repeat, repeat;
  background-size: 100% 100%, cover, 260px 260px;
  background-attachment: fixed;
}

/* ── Shared launcher chrome (Home + group pages) ──────────── */
html.theme-map .home-header {
  background: transparent;
  border: 0;
  padding: var(--s2) var(--s2) 0;
  margin-bottom: var(--s2);
  overflow: visible;
}
html.theme-map .home-header::before { display: none; }
html.theme-map .home-header .home-status-dot,
html.theme-map .home-header .home-eyebrow,
html.theme-map .home-header .ops-clock,
html.theme-map #dark-mode-toggle,
html.theme-map .home-grid-caption,
html.theme-map #page-home > .module-grid { display: none; }

html.theme-map .home-icon-btn {
  border: 1px solid var(--map-ink-faint);
  color: var(--map-ink);
  background: transparent;
}
html.theme-map .home-icon-btn:active { background: var(--map-wash); border-color: var(--map-ink-soft); }
html.theme-map .home-header-top { justify-content: flex-end; }
html.theme-map .page-group .home-header-top { justify-content: flex-start; }

html.theme-map .home-logout-btn {
  border: 0;
  border-bottom: 1px dotted var(--map-ink-soft);
  border-radius: 0;
  color: var(--map-ink);
  font-family: var(--map-font);
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  padding: 2px 2px;
  margin-left: var(--s2);
}

html.theme-map #page-home h1,
html.theme-map .page-group h1 {
  font-family: var(--map-font-sc);
  font-weight: 400;
  color: var(--map-ink);
  text-shadow: var(--map-glow);
}
html.theme-map .home-subhead {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 15px;
  color: var(--map-ink-soft);
  letter-spacing: 0;
}

/* ── Home: cartouche ──────────────────────────────────────── */
html.theme-map .map-cartouche {
  text-align: center;
  color: var(--map-ink);
  text-shadow: var(--map-glow);
  padding: var(--s1) var(--s4) var(--s2);
  position: relative;
}
html.theme-map .map-cartouche::before,
html.theme-map .map-cartouche::after {
  content: '';
  display: block;
  height: 10px;
  margin: 0 auto;
  width: 70%;
  border-top: 1px solid var(--map-ink-soft);
  border-bottom: 1px solid var(--map-ink-faint);
}
html.theme-map .map-cartouche::before { margin-bottom: var(--s2); }
html.theme-map .map-cartouche::after { margin-top: var(--s2); height: 4px; }
html.theme-map .map-c-names {
  font-family: var(--map-font-sc);
  font-size: 18px;
  letter-spacing: 0.04em;
}
html.theme-map .map-c-small {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 13px;
  line-height: 1.35;
  color: var(--map-ink-soft);
}
html.theme-map .map-c-title {
  font-family: var(--map-font-title);
  font-weight: 400;
  font-size: clamp(26px, 8.4vw, 42px);
  white-space: nowrap;
  line-height: 1.1;
  margin-top: 2px;
}
html.theme-map #page-home h1#home-greeting {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 16px;
  text-align: center;
  color: var(--map-ink-soft);
  margin-top: var(--s1);
}
html.theme-map #page-home .home-subhead { display: none; }

/* One-time reveal on show (the shell toggles display, so it replays). */
html.theme-map .map-cartouche,
html.theme-map #home-greeting {
  animation: map-fade-in 0.9s ease both;
}

/* ── Home: the map ────────────────────────────────────────── */
html.theme-map #page-home { overflow-y: auto; }
html.theme-map .map-sheet {
  flex-shrink: 0;
  margin: 0 calc(var(--s2) * -1);
  transition: transform 0.48s cubic-bezier(0.55, 0, 0.6, 1), opacity 0.48s ease;
  will-change: transform;
}
html.theme-map .map-sheet.map-zooming {
  transform: scale(2.8);
  opacity: 0;
}
html.theme-map .map-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

html.theme-map .map-svg .ink-line {
  fill: none;
  stroke: var(--map-ink);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: map-ink-draw var(--map-draw) cubic-bezier(0.45, 0.05, 0.4, 1) forwards;
  animation-delay: calc(var(--i, 0) * var(--map-stagger));
}
html.theme-map.map-night .map-svg .map-ink { filter: url(#map-ink-filter) drop-shadow(0 0 2px rgba(240, 185, 80, 0.5)); }
html.theme-map .map-svg .wall    { stroke-width: 7; }
html.theme-map .map-svg .room    { stroke-width: 2.6; }
html.theme-map .map-svg .fitting { stroke-width: 1.6; stroke: var(--map-ink-soft); }
html.theme-map .map-svg .path-dash {
  stroke-width: 2;
  stroke: var(--map-ink-soft);
  stroke-dasharray: 0.012 0.008;
  stroke-dashoffset: 0;
  animation: map-fade-in 0.6s ease both;
  animation-delay: var(--map-draw);
}

html.theme-map .map-svg text {
  fill: var(--map-ink);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--map-paper);
  stroke-width: 6px;
  stroke-linejoin: round;
}
html.theme-map .map-svg .ink-text {
  opacity: 0;
  animation: map-fade-in 0.7s ease forwards;
  animation-delay: calc(var(--map-draw) * 0.75);
}
html.theme-map .map-room-name {
  font-family: var(--map-font-sc);
  font-size: 28px;
  letter-spacing: 0.02em;
}
html.theme-map .map-room-name--small { font-size: 22px; }
html.theme-map .map-room-sub {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 24px;
  fill: var(--map-ink-soft) !important;
}
html.theme-map .map-floor-label {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 30px;
  text-anchor: start !important;
}
html.theme-map .map-sign {
  font-family: var(--map-font-sc);
  font-size: 26px;
}
html.theme-map .map-sign--small {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 20px;
}

/* Tap targets: invisible until pressed, then an ink wash. */
html.theme-map .map-room {
  fill: transparent;
  cursor: pointer;
  outline: none;
  transition: fill 0.25s ease;
}
html.theme-map .map-room:hover,
html.theme-map .map-room:focus-visible { fill: var(--map-wash); }
html.theme-map .map-room:active,
html.theme-map .map-room--entering { fill: var(--map-wash); stroke: var(--map-ink-soft); stroke-width: 2; }

/* Footprints and name banners */
html.theme-map .map-footprint {
  fill: var(--map-ink);
  opacity: 0;
  animation: map-step 3s ease-out forwards;
}
html.theme-map.map-night .map-footprint { filter: drop-shadow(0 0 2px rgba(240, 185, 80, 0.8)); }
html.theme-map .map-person {
  transition: transform 0.15s linear, opacity 0.5s ease;
  animation: map-fade-in 0.6s ease both;
}
html.theme-map .map-banner {
  fill: var(--map-paper);
  stroke: var(--map-ink);
  stroke-width: 2;
}
html.theme-map .map-banner-text {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 24px;
  stroke-width: 0 !important;
}

/* Margin note under the map: written in, as if by an unseen hand. */
html.theme-map .map-note {
  flex-shrink: 0;
  font-family: var(--map-font);
  font-style: italic;
  font-size: 15px;
  line-height: 1.45;
  color: var(--map-ink);
  text-shadow: var(--map-glow);
  text-align: center;
  padding: var(--s3) var(--s5) var(--s5);
  min-height: 4.5em;
}

/* Hand-written reveal, left to right */
html.theme-map .map-write {
  animation: map-write 1.6s steps(28, end) both;
}

/* ── Group pages (Travel, Money) ──────────────────────────── */
html.theme-map .module-tile {
  background: var(--map-paper-2);
  background-image: var(--map-grain);
  border: 1.5px solid var(--map-ink);
  border-radius: 3px;
  box-shadow: inset 0 0 0 4px var(--map-paper-2), inset 0 0 0 5px var(--map-ink-faint), 0 3px 10px rgba(60, 30, 8, 0.22);
  font-family: var(--map-font-sc);
}
html.theme-map .module-tile:active { background-color: var(--map-paper-deep); }
html.theme-map .module-tile::before,
html.theme-map .module-tile::after { border-color: var(--map-ink-soft); width: 10px; height: 10px; }
html.theme-map .module-tile-code,
html.theme-map .module-tile-status { display: none; }
html.theme-map .module-tile-icon { color: var(--map-ink); }
html.theme-map .module-tile-label {
  font-family: var(--map-font-sc);
  font-weight: 400;
  font-size: 18px;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--map-ink);
  text-shadow: var(--map-glow);
}

/* ── Module headers: a parchment banner over each module ─────
   :is(#page-home, [id^="module-"]) carries id-level specificity whichever
   argument matches, so this beats every module's own header rule (e.g.
   #module-atc .mod-header) without !important. */
html.theme-map :is(#page-home, [id^="module-"]) .mod-header {
  background: var(--map-paper-2);
  background-image: var(--map-grain);
  border: 1.5px solid var(--map-ink);
  border-radius: 3px;
  box-shadow: inset 0 0 0 4px var(--map-paper-2), inset 0 0 0 5px var(--map-ink-faint), 0 3px 10px rgba(60, 30, 8, 0.25);
  color: var(--map-ink);
  --mod-header-accent: var(--map-ink-soft);
}
html.theme-map :is(#page-home, [id^="module-"]) .mod-header-title {
  font-family: var(--map-font-sc);
  font-weight: 400;
  color: var(--map-ink);
  letter-spacing: 0.02em;
  text-transform: none;
  text-shadow: var(--map-glow);
}
html.theme-map :is(#page-home, [id^="module-"]) .mod-header-status {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--map-ink-soft);
}
html.theme-map :is(#page-home, [id^="module-"]) .mod-header-status::before { box-shadow: none; }
/* Emoji/icon buttons in headers: aged to sepia so they sit on the parchment. */
html.theme-map :is(#page-home, [id^="module-"]) .mod-header .home-btn,
html.theme-map :is(#page-home, [id^="module-"]) .mod-header .settings-btn {
  color: var(--map-ink);
  opacity: 1;
  filter: sepia(1) saturate(0.7) brightness(0.85);
}

/* ── Login ritual ─────────────────────────────────────────── */
html.theme-map .login-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  text-align: center;
  max-width: 400px;
}
html.theme-map .login-panel::before,
html.theme-map .login-panel::after,
html.theme-map .login-panel-topline,
html.theme-map #page-login h1,
html.theme-map #page-login .home-subhead,
html.theme-map .login-divider,
html.theme-map .login-error,
html.theme-map .login-btn-arrow,
html.theme-map #login-btn-label { display: none !important; }

html.theme-map .map-login-title {
  font-family: var(--map-font-title);
  font-weight: 400;
  font-size: 42px;
  color: var(--map-ink);
  text-shadow: var(--map-glow);
  opacity: 0.85;
  animation: map-fade-in 1.4s ease both;
}
html.theme-map .map-swear {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 19px;
  line-height: 1.4;
  color: var(--map-ink);
  text-shadow: var(--map-glow);
  margin: var(--s3) 0 var(--s5);
  animation-delay: 0.6s;
}
html.theme-map #login-form { animation: map-fade-in 0.8s ease 2s both; }
html.theme-map .login-field-label {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--map-ink-soft);
  text-align: left;
}
html.theme-map .login-input {
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--map-ink-soft);
  border-radius: 0;
  color: var(--map-ink);
  font-family: var(--map-font);
  font-size: 19px;
  padding: 6px 2px;
}
html.theme-map .login-input::placeholder { color: var(--map-ink-faint); font-style: italic; }
html.theme-map .login-input:focus { border-bottom-color: var(--map-ink); box-shadow: none; outline: none; }
html.theme-map .login-submit-btn {
  background: transparent;
  border: 1.5px solid var(--map-ink);
  border-radius: 3px;
  box-shadow: inset 0 0 0 3px var(--map-paper), inset 0 0 0 4px var(--map-ink-faint);
  color: var(--map-ink);
  font-family: var(--map-font-sc);
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: none;
  justify-content: center;
}
html.theme-map .login-submit-btn::after { content: 'Reveal the map'; }
html.theme-map .login-submit-btn:disabled::after { content: 'The ink is drying\2026'; }
html.theme-map .login-submit-btn:active { background: var(--map-wash); }
html.theme-map .map-insult {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 16px;
  line-height: 1.4;
  color: var(--map-red);
  margin-top: var(--s2);
  min-height: 1.4em;
  transform: rotate(-1.5deg);
}

/* ── Veil: full-screen parchment moments ──────────────────── */
html.theme-map .map-veil {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
/* Login: a blot of ink spreads from the centre and soaks into the page
   while the house draws itself underneath. */
html.theme-map .map-veil--bloom::before {
  content: '';
  width: 40vmax;
  height: 40vmax;
  border-radius: 50%;
  background: radial-gradient(circle, var(--map-ink) 0 30%, rgba(58, 35, 19, 0.6) 48%, transparent 70%);
  animation: map-bloom 1.3s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
/* Logout: the page goes blank, "Mischief managed." is written, then the
   veil lifts to the blank login parchment. */
html.theme-map .map-veil--managed {
  background-color: var(--map-paper);
  background-image: var(--map-stains), var(--map-grain);
  animation: map-veil-managed 2.6s ease forwards;
}
html.theme-map .map-veil-text {
  font-family: var(--map-font);
  font-style: italic;
  font-size: 30px;
  color: var(--map-ink);
  text-shadow: var(--map-glow);
}

/* ── Settings + theme picker sheets ──────────────────────── */
html.theme-map .modal-sheet.shell-modal-sheet {
  background-color: var(--map-paper);
  background-image: var(--map-grain);
  border-top: 1.5px solid var(--map-ink);
}
html.theme-map .shell-modal-sheet .modal-sheet-title {
  font-family: var(--map-font-sc);
  font-weight: 400;
  color: var(--map-ink);
}
html.theme-map .shell-modal-sheet .modal-sheet-sub,
html.theme-map .shell-modal-sheet .theme-picker-blurb { color: var(--map-ink-soft); font-family: var(--map-font); font-style: italic; }
html.theme-map .shell-modal-sheet .modal-close-btn { background: var(--map-paper-2); color: var(--map-ink); }
html.theme-map .shell-modal-sheet .modal-confirm-btn { background: var(--map-ink); color: var(--map-paper); font-family: var(--map-font-sc); }
html.theme-map .shell-settings-nav-row {
  font-family: var(--map-font);
  font-size: 17px;
  color: var(--map-ink);
  border-top-color: var(--map-ink-faint);
}
html.theme-map .shell-settings-nav-row:active { background: var(--map-wash); }
html.theme-map .shell-settings-nav-chevron,
html.theme-map .theme-picker-check { color: var(--map-ink-soft); }

/* ── Keyframes ────────────────────────────────────────────── */
@keyframes map-ink-draw { to { stroke-dashoffset: 0; } }
@keyframes map-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes map-write {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}
@keyframes map-step {
  0%   { opacity: 0; }
  8%   { opacity: 0.95; }
  55%  { opacity: 0.75; }
  100% { opacity: 0; }
}
@keyframes map-bloom {
  0%   { transform: scale(0.05); opacity: 0.95; }
  45%  { opacity: 0.85; }
  100% { transform: scale(3.2); opacity: 0; }
}
@keyframes map-veil-managed {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* No big motion for anyone who's asked their phone for less. */
@media (prefers-reduced-motion: reduce) {
  html.theme-map .map-svg .ink-line,
  html.theme-map .map-svg .ink-text,
  html.theme-map .map-write,
  html.theme-map #login-form,
  html.theme-map .map-cartouche,
  html.theme-map #home-greeting {
    animation: none !important;
    stroke-dashoffset: 0;
    opacity: 1;
    clip-path: none;
  }
  html.theme-map .map-sheet { transition: none; }
}
