/* Tanaw Earth. Tokens and sizes follow DESIGN.md. Colours only through the tokens below. */

@font-face {
  font-family: "Michroma";
  src: url("fonts/michroma-tanaw.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+41, U+45, U+48, U+4E, U+52, U+54, U+57;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-latin-ext.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Spline Sans Mono";
  src: url("fonts/spline-sans-mono-latin.woff2") format("woff2");
  font-weight: 500 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Spline Sans Mono";
  src: url("fonts/spline-sans-mono-latin-ext.woff2") format("woff2");
  font-weight: 500 600;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Away from the picture (sheets and dialogs): light theme */
  --bg: #ffffff;
  --surface: #f0f0f0;
  --ink: #111111;
  --muted: #555555;
  --line: #dadada;
  --brand-arc: #1d7a44;
  --accent: var(--ink);
  --accent-ink: var(--ink);
  --on-accent: var(--bg);

  /* On the picture: the same in both themes */
  --space: #000000;
  --scrim: rgba(10, 10, 10, .72);
  --pic-ink: #f2f2f2;
  --pic-muted: #c4c4c4;
  --pic-line: rgba(242, 242, 242, .28);
  --brand-arc-on-space: #6fe08a;

  --sans: "Onest", sans-serif;
  --mono: "Spline Sans Mono", monospace;
  --logo: "Michroma", sans-serif;
  --halo: 0 1px 3px var(--space), 0 0 1px var(--space);
  --radius-control: 10px;
  --radius-card: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080808;
    --surface: #131313;
    --ink: #eeeeee;
    --muted: #a0a0a0;
    --line: #222222;
    --brand-arc: #6fe08a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #080808;
  --surface: #131313;
  --ink: #eeeeee;
  --muted: #a0a0a0;
  --line: #222222;
  --brand-arc: #6fe08a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: var(--space);
  color: var(--pic-ink);
  font: 400 15px/1.4 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
p { margin: 0; }
button { font: inherit; }

/* The picture fills the screen; words sit at the top, controls at the bottom. */
#map { position: fixed; inset: 0; }
.scrim { position: fixed; left: 0; right: 0; z-index: 1; pointer-events: none; }
.scrim-top { top: 0; height: 30%; background: linear-gradient(var(--scrim), transparent); }
.scrim-bottom { bottom: 0; height: 32%; background: linear-gradient(transparent, var(--scrim)); }

/* Overlay rows let drags through to the map except on their controls. */
.top, .stamp, .dock { position: fixed; z-index: 2; pointer-events: none; }
.top-actions, .switch, .timebar { pointer-events: auto; }

.top {
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.wordmark { color: var(--pic-ink); white-space: nowrap; --m-el: var(--pic-ink); --m-sun: var(--pic-ink); --m-glow: var(--brand-arc-on-space); }
/* The SVG's bottom edge sits 2.5 px below the TANAW baseline; this puts both words on one baseline. */
.wordmark svg { width: auto; height: 20px; vertical-align: -2.5px; filter: drop-shadow(0 1px 3px var(--space)); }
.wordmark span { margin-left: 8px; font: 400 13px/1 var(--logo); letter-spacing: .32em; text-shadow: var(--halo); }
.top-actions { display: flex; gap: 8px; }

.icon-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--scrim);
  color: var(--pic-ink);
  cursor: pointer;
}
.icon { width: 22px; height: 22px; }

/* Picture stamp: place, age, source */
.stamp {
  top: calc(max(8px, env(safe-area-inset-top)) + 48px);
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  text-shadow: var(--halo);
}
.place { font: 700 20px/1.15 var(--sans); }
.age { margin-top: 2px; font: 600 30px/1.1 var(--sans); }
.source { margin-top: 2px; font: 400 12px/1.4 var(--sans); color: var(--pic-muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.place .num { font-weight: 600; }

/* Bottom: the picture switch, then the time bar */
.dock {
  left: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 560px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 max(10px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
.switch { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.switch button {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--scrim);
  color: var(--pic-ink);
  font: 600 12px/1.1 var(--sans);
  cursor: pointer;
}
.switch button[aria-pressed="true"] { background: var(--pic-ink); color: var(--space); }

.timebar { display: flex; align-items: center; gap: 6px; }
#locate-button { margin-left: auto; }

#track {
  flex: 1;
  min-width: 0;
  height: 44px;
  margin: 0;
  border-radius: var(--radius-control);
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
#track::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--pic-line); }
#track::-moz-range-track { height: 4px; border-radius: 2px; background: var(--pic-line); }
#track::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 0;
  border-radius: 50%;
  background: var(--pic-ink);
  box-shadow: var(--halo);
}
#track::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--pic-ink); box-shadow: var(--halo); }

/* Keyboard focus on the picture */
.top :focus-visible,
.dock :focus-visible,
.maplibregl-canvas:focus-visible { outline: 2px solid var(--pic-ink); outline-offset: 2px; }
.maplibregl-canvas:focus-visible { outline-offset: -2px; }

/* Toast: above the controls, centred */
.toast {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 108px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: var(--radius-control);
  background: var(--scrim);
  color: var(--pic-ink);
  font: 600 15px/1.3 var(--sans);
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
  visibility: hidden;
}
.toast.shown { visibility: visible; }

/* Sheets: away from the picture, so they follow the theme. Bottom sheet on phones, centred from 600 px. */
.sheet {
  width: 100%;
  max-width: none;
  max-height: 85dvh;
  margin: auto 0 0;
  padding: 0 16px max(16px, env(safe-area-inset-bottom));
  border: 0;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  background: var(--surface);
  color: var(--ink);
  font: 400 15px/1.45 var(--sans);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet::backdrop { background: var(--scrim); }
/* A fixed height keeps the search field near the top, above a phone's keyboard, while results change. */
.search-sheet { height: 85dvh; }
@media (min-width: 600px) {
  .sheet { width: 420px; margin: auto; padding-bottom: 16px; border-radius: var(--radius-card); }
  .search-sheet { height: min(480px, 85dvh); }
}

.sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.sheet-head h2 { flex: 1; margin: 0; font: 700 20px/1.2 var(--sans); }
.sheet-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.sheet :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* 16 px keeps phones from zooming in when the field takes focus. */
#search-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1 var(--sans);
}
#search-input::placeholder { color: var(--muted); opacity: 1; }
.results { margin: 0; padding: 0; list-style: none; }
.results li + li { border-top: 1px solid var(--line); }
.results button {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 400 16px/1.3 var(--sans);
  text-align: left;
  cursor: pointer;
}
.sheet-note { padding: 14px 4px; color: var(--muted); }

.about-sheet p { margin-top: 12px; }
.about-sheet h3 { margin: 20px 0 8px; padding-top: 16px; border-top: 1px solid var(--line); font: 700 15px/1.3 var(--sans); }
.about-list { margin: 12px 0 0; }
.about-list dt { font-weight: 700; }
.about-list dd { margin: 0 0 8px; color: var(--muted); }
.theme-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.theme-choice button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--bg);
  color: var(--ink);
  font: 600 15px/1 var(--sans);
  cursor: pointer;
}
.theme-choice button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.sheet-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); font-weight: 600; }
