/* Date My Map: minimal Windows 98. Navy is used only for the date range. */

:root {
  --bg: #c0c0c0;
  --text: #000000;
  --text-2: #202020;
  --text-3: #404040;
  --navy: #000080;
  --white: #ffffff;

  --pixel: "DotGothic16", ui-monospace, monospace;
  --body: "Arimo", Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

/* ── Screen ─────────────────────────────────────────────────────────────── */

.screen {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 430px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 56px 20px 28px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

/* ── Building blocks ────────────────────────────────────────────────────── */

.raised {
  background: var(--bg);
  border: 2px solid;
  border-color: #ffffff #404040 #404040 #ffffff;
  box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #dfdfdf;
  border-radius: 0;
  cursor: pointer;
}

.raised:active {
  border-color: #404040 #ffffff #ffffff #404040;
  box-shadow: inset 1px 1px 0 #808080, inset -1px -1px 0 #dfdfdf;
}

.raised:focus-visible {
  outline: 1px dotted var(--text);
  outline-offset: -6px;
}

.sunken {
  background: var(--white);
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  box-shadow: inset 1px 1px 0 #404040;
}

/* ── Welcome ────────────────────────────────────────────────────────────── */

.welcome {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.welcome-mascot {
  width: 128px;
  height: auto;
}

.title {
  margin: 28px 0 0;
  font-family: var(--pixel);
  font-size: 44px;
  font-weight: 400;
  line-height: 1.1;
}

.tagline {
  margin: 18px 0 36px;
  font-size: 16px;
  color: var(--text-2);
}

.start {
  width: 100%;
  min-height: 76px;
  font-family: var(--pixel);
  font-size: 24px;
}

/* Pinned to the bottom of the welcome screen. */
.credit {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 12px;
  font-size: 14px;
  color: var(--text-3);
}

.credit:focus-visible {
  outline: 1px dotted var(--text);
}

/* Text links to the timeline: black, underlined, with a 44px tap area. */
.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 6px;
  padding: 0 8px;
  font-size: 15px;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-link:focus-visible {
  outline: 1px dotted var(--text);
}

/* ── Start-over mascot (top middle) ─────────────────────────────────────── */

.home {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 48px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.home:focus-visible {
  outline: 1px dotted var(--text);
}

.home-mascot {
  width: 36px;
  height: auto;
}

/* ── Range and timeline ─────────────────────────────────────────────────── */

.range {
  margin: 0 0 8px;
  font-family: var(--pixel);
  font-size: 24px;
  line-height: 1.2;
  color: var(--navy);
}

.timeline {
  position: relative;
  height: 22px;
}

.timeline-block {
  position: absolute;
  top: 1px;
  bottom: 1px;
  min-width: 6px;
  background: var(--navy);
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-2);
}

/* ── Question ───────────────────────────────────────────────────────────── */

.question {
  margin: 48px 0 0;
  font-family: var(--pixel);
  font-size: 36px;
  font-weight: 400;
  line-height: 1.15;
}

.fact {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-2);
}

/* The drawn ↗ arrow in "learn more ↗". */
.arrow {
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  vertical-align: 0.05em;
}

/* Inline at the end of the fun fact. */
/* Vertical padding on an inline link grows its tap area to about 44px
   without changing the line spacing. */
.learn-more {
  padding: 12px 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.learn-more:focus-visible {
  outline: 1px dotted var(--text);
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 24px;
}

.answer {
  min-height: 60px;
  padding: 6px 8px;
  font-family: var(--pixel);
  font-size: 21px;
  line-height: 1.1;
}

.skip {
  align-self: flex-start;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 14px;
  color: var(--text-3);
  cursor: pointer;
}

.skip:focus-visible {
  outline: 1px dotted var(--text);
}

/* ── Result ─────────────────────────────────────────────────────────────── */

.result {
  text-align: center;
}

.result .timeline-labels,
.result .known {
  text-align: left;
}

/* The framed pixel map, with crop marks and the "Case closed!" burst. */
.map {
  position: relative;
  margin: 24px 14px 36px;
}

.map-frame {
  display: block;
  line-height: 0;
}

.map-frame svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Sparkles: chunky black plus signs around the map, a little off-square.
   They blink a couple of times once the map has filled in. */
.sparkle {
  position: absolute;
  width: 22px;
  height: 22px;
  animation: sparkle-blink 900ms steps(1) 600ms both;
}

.sparkle::before,
.sparkle::after {
  content: "";
  position: absolute;
  background: var(--text);
}

.sparkle::before {
  top: 50%;
  left: 0;
  width: 100%;
  height: 3px;
  transform: translateY(-50%);
}

.sparkle::after {
  top: 0;
  left: 50%;
  width: 3px;
  height: 100%;
  transform: translateX(-50%);
}

.sparkle-tl {
  top: -20px;
  left: -16px;
}

.sparkle-bl {
  bottom: -30px;
  left: -6px;
  width: 16px;
  height: 16px;
  animation-delay: 750ms;
}

.sparkle-br {
  right: -16px;
  bottom: -24px;
  animation-delay: 680ms;
}

@keyframes sparkle-blink {
  0%,
  50% {
    opacity: 0;
  }
  25%,
  75%,
  100% {
    opacity: 1;
  }
}

/* The map fills in three rows at a time (--group is set per row). */
.map-row {
  animation: map-fill 1ms calc(var(--group) * 100ms) both;
}

@keyframes map-fill {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sparkle,
  .map-row {
    animation: none;
  }
}

.result-intro {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--text-2);
}

.range-big {
  margin-bottom: 20px;
  font-size: 60px;
  line-height: 1.05;
}

.known.known-result {
  margin: 0 0 24px;
  padding-top: 32px;
}

.known-result .known-list {
  height: 176px;
}

.again {
  width: 100%;
  min-height: 60px;
  margin-top: auto;
  font-family: var(--pixel);
  font-size: 22px;
}

/* ── Pop-up notes ───────────────────────────────────────────────────────── */

/* A note pops in a second after its page appears and stays put. It never
   takes taps or moves the layout. The 1s delay matches DELAY_MS in notes.js. */
.note {
  position: absolute;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 124px;
  height: 92px;
  pointer-events: none;
  transform: rotate(8deg);
  animation: note-in 220ms cubic-bezier(0.3, 1.6, 0.6, 1) 1s both;
}

.note svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.note-text {
  position: relative;
  max-width: 64px;
  font-family: var(--pixel);
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
}

/* On question pages: the top right corner. */
.note-corner {
  top: 10px;
  right: 6px;
}

/* On the result page: overlapping the map's top right corner. */
.note-on-map {
  top: -46px;
  right: -30px;
}

@keyframes note-in {
  from {
    opacity: 0;
    transform: rotate(8deg) scale(0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .note {
    animation: none;
  }
}

/* ── What we know ───────────────────────────────────────────────────────── */

.known {
  margin-top: auto;
  padding-top: 24px;
}

.known-label {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text-2);
}

.known-list {
  height: 168px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: #c0c0c0 #dfdfdf;
}

.known-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  background: none;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.known-row:hover {
  background: #efefef;
}

.known-row:focus-visible {
  outline: 1px dotted var(--text);
  outline-offset: -2px;
}

.known-row-result {
  cursor: default;
}

.known-row-result:hover {
  background: none;
}

/* "learn more ↗" under each result row. The invisible ::after makes the tap
   area about 44px tall without changing the layout. */
.read-more {
  position: relative;
  display: block;
  width: fit-content;
  margin-top: 2px;
  padding: 2px 0;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.read-more::after {
  content: "";
  position: absolute;
  inset: -10px -6px;
}

.read-more:focus-visible {
  outline: 1px dotted var(--text);
}

.known-years {
  flex-shrink: 0;
  font-weight: 700;
}

/* Chunky retro scrollbar (Chrome, Safari, Edge). */
html::-webkit-scrollbar,
.known-list::-webkit-scrollbar {
  width: 18px;
}

html::-webkit-scrollbar-track,
.known-list::-webkit-scrollbar-track {
  background-color: #dfdfdf;
  background-image: conic-gradient(#c0c0c0 25%, transparent 0 50%, #c0c0c0 0 75%, transparent 0);
  background-size: 2px 2px;
}

html::-webkit-scrollbar-thumb,
.known-list::-webkit-scrollbar-thumb {
  background: var(--bg);
  border: 2px solid;
  border-color: #ffffff #404040 #404040 #ffffff;
  box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #dfdfdf;
}

/* ── Timeline: map changes ──────────────────────────────────────────────── */
/* Phone first: a line down the left, year left of it, card right of it. */

.tl-page {
  position: relative;
  max-width: 430px;
  margin: 0 auto;
  padding: 56px 20px 48px;
}

/* On a phone the home mascot stays pinned at the top while you scroll, on a
   grey strip so cards slide underneath it. */
.tl-page::before {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 3;
  height: 52px;
  background: var(--bg);
}

.tl-page .home {
  position: fixed;
  top: 4px;
  z-index: 4;
}

.tl-heading {
  margin: 8px 0 0;
  font-family: var(--pixel);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.1;
}

.tl-sub {
  margin: 4px 0 16px;
  font-size: 15px;
  color: var(--text-2);
}

.tl-jump {
  display: none;
}

/* Decade headers stick just under the pinned mascot while their events
   scroll past. */
.tl-decade {
  position: sticky;
  top: 52px;
  z-index: 2;
  margin: 0;
  padding: 12px 0 6px;
  border-bottom: 1px solid #808080;
  background: var(--bg);
  font-family: var(--pixel);
  font-size: 20px;
  font-weight: 400;
}

.tl-events {
  position: relative;
  margin: 0;
  padding: 14px 0 6px;
  list-style: none;
}

.tl-events::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 52px;
  width: 2px;
  background: var(--text);
}

.tl-event {
  position: relative;
  margin-bottom: 14px;
  padding-left: 66px;
}

.tl-year {
  position: absolute;
  top: 6px;
  left: 0;
  width: 42px;
  font-family: var(--pixel);
  font-size: 14px;
  text-align: right;
}

.tl-marker {
  position: absolute;
  top: 8px;
  left: 48px;
  width: 10px;
  height: 10px;
  background: var(--text);
}

.tl-card {
  padding: 10px 12px 8px;
  text-align: left;
}

.tl-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tl-minimap {
  flex-shrink: 0;
  width: 64px;
  line-height: 0;
}

.tl-minimap svg {
  display: block;
  width: 100%;
  height: auto;
}

.tl-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.tl-blurb {
  margin: 8px 0 2px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-2);
}

.tl-card .learn-more {
  font-size: 13px;
}

/* Desktop: sidebar with "Jump to"; the line runs down the centre and cards
   alternate sides, with the year opposite each card. */
@media (min-width: 900px) {
  .tl-page {
    display: grid;
    grid-template-columns: 340px 1fr;
    max-width: none;
    min-height: 100vh;
    padding: 0;
  }

  .tl-sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    padding: 72px 32px 32px;
    border-right: 1px solid #808080;
  }

  /* The sidebar doesn't scroll, so the mascot just sits at its top. */
  .tl-page::before {
    display: none;
  }

  .tl-page .home {
    position: absolute;
    top: 16px;
    left: 32px;
    transform: none;
  }

  .tl-heading {
    margin-top: 0;
    font-size: 44px;
  }

  .tl-sub {
    margin-bottom: 28px;
  }

  .tl-jump {
    display: block;
  }

  .tl-jump-label {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--text-2);
  }

  .tl-jump-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }

  .tl-jump-grid button {
    min-height: 32px;
    font-family: var(--pixel);
    font-size: 14px;
  }

  .tl-main {
    padding: 16px 40px 96px;
  }

  /* Decade labels: small raised boxes on the line. */
  .tl-decade {
    top: 12px;
    padding: 10px 0;
    border: 0;
    background: none;
    text-align: center;
  }

  .tl-decade span {
    display: inline-block;
    padding: 4px 12px;
    background: var(--bg);
    border: 2px solid;
    border-color: #ffffff #404040 #404040 #ffffff;
    box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #dfdfdf;
    font-size: 18px;
  }

  .tl-events::before {
    left: 50%;
    transform: translateX(-1px);
  }

  .tl-event {
    display: grid;
    grid-template-columns: 1fr 64px 1fr;
    align-items: start;
    margin-bottom: 20px;
    padding-left: 0;
  }

  .tl-marker {
    position: static;
    grid-row: 1;
    grid-column: 2;
    justify-self: center;
    width: 14px;
    height: 14px;
    margin-top: 10px;
  }

  .tl-year {
    position: static;
    grid-row: 1;
    width: auto;
    padding-top: 6px;
    font-size: 18px;
  }

  .tl-card {
    grid-row: 1;
    width: 100%;
    max-width: 320px;
  }

  .tl-left .tl-card {
    grid-column: 1;
    justify-self: end;
  }

  .tl-left .tl-year {
    grid-column: 3;
    justify-self: start;
  }

  .tl-right .tl-card {
    grid-column: 3;
    justify-self: start;
  }

  .tl-right .tl-year {
    grid-column: 1;
    justify-self: end;
  }

  .tl-minimap {
    width: 80px;
  }
}
