/* Atlas: a school atlas on the table. Information sits on paper or on label tape; the map lies underneath.
   Palette and pieces mirror the app (ios/Atlas/MapView.swift, AtlasCollage.swift). */

:root {
  --water: #bdded9;
  --land: #f2e8cc;
  --paper: #fbf7ee;
  --surface: #fff;      /* label tape */
  --ink: #1c2629;
  --muted: #4a5557;     /* opaque surfaces only */
  --blue: #1e4d66;      /* actions and links */
  --yellow: #ffc943;    /* the title tape and picture mats: decoration only */
  --red: #b83a2e;       /* the voyage line and the stamp */
  --border: #6e5b43;
  --line: rgb(28 38 41 / 0.12);
  --shadow: rgb(28 38 41 / 0.14);
  --hard-shadow: 3px 4px 0 var(--shadow); /* collage shadow: offset, never blurred */

  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --radius-button: 999px; /* every button is the same pill */
  --space: clamp(1.25rem, 4vw, 2rem);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--water);
  color: var(--ink);
  font: 1.0625rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* The map: a fixed layer instead of background-attachment: fixed, which iOS Safari ignores.
   Each page points the camera somewhere else, like the app does. */
body::before {
  content: "";
  position: fixed;
  inset: -4rem 0;
  z-index: -1;
  background: var(--water) url("atlas-map.jpg") var(--map-x, 45%) var(--map-y, 40%) / cover no-repeat;
}
[data-camera="new-york"] { --map-x: 6%; --map-y: 45%; }
[data-camera="lisbon"] { --map-x: 84%; --map-y: 52%; }
[data-camera="greenwich"] { --map-x: 96%; --map-y: 22%; }
[data-camera="open-sea"] { --map-x: 50%; --map-y: 80%; }

/* Scrolling drifts the map a little, as in the app. Decorative, so no fallback. */
@keyframes drift { to { translate: 0 -4rem; } }
@supports ((animation-timeline: scroll()) and (animation-range: entry)) { /* "entry" filters out partial support */
  @media (prefers-reduced-motion: no-preference) {
    body::before {
      animation: drift linear both;
      animation-timeline: scroll(root);
    }
  }
}

img { max-width: 100%; height: auto; }

a { color: var(--blue); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h2, h3 { font-family: var(--serif); font-weight: 700; }
p { margin: 0 0 1em; text-wrap: pretty; }
p:last-child, ul:last-child, dl:last-child { margin-bottom: 0; }

.wrap { width: min(100% - 2.5rem, 68rem); margin-inline: auto; }

.skip {
  position: absolute;
  left: 1rem;
  top: -10rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--hard-shadow);
}
.skip:focus { top: 1rem; }

/* ---- Tape ---- */

/* Text that sits on the map gets its own solid block per line. */
.tape {
  background: var(--surface);
  padding: 0.12em 0.4em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.mono { font-family: var(--mono); font-size: 0.9375rem; letter-spacing: -0.01em; }
.on-map { line-height: 1.85; max-width: 38rem; }
.on-map.muted .tape { color: var(--muted); }

/* The one yellow title strip per page: slightly tilted, wiped in once. */
.title-tape {
  display: inline-block;
  margin: 0;
  padding: 0.06em 0.22em 0.1em;
  background: var(--yellow);
  font: 900 clamp(2.25rem, 9vw, 4rem)/1.05 var(--serif);
  letter-spacing: -0.01em;
  rotate: -2deg;
}
.title-tape.wordmark { font-size: clamp(3.5rem, 16vw, 6.75rem); line-height: 1; }
@media (prefers-reduced-motion: no-preference) {
  .title-tape { animation: wipe 0.45s 0.15s ease-out both; }
}
@keyframes wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }

/* ---- Header and footer ---- */

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 1.25rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem 0.3rem 0.3rem;
  background: var(--surface);
  color: var(--ink);
  font: 700 1.25rem/1 var(--serif);
  text-decoration: none;
}
.brand img { width: 2rem; height: 2rem; border-radius: 0.45rem; }
.site-nav ul { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.site-nav a {
  display: inline-block;
  padding: 0.45rem 0.7rem;
  background: var(--surface);
  color: var(--ink);
  font: 600 0.875rem/1.2 var(--mono);
  text-decoration: none;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.25em; }

main { flex: 1; padding-bottom: clamp(3rem, 8vw, 5rem); }

.site-footer {
  background: var(--paper);
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
  color: var(--muted);
}
.site-footer .wrap { display: grid; gap: 1rem; padding-block: 2rem 2.5rem; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin: 0; padding: 0; list-style: none; }
.site-footer a { font-weight: 600; }
.site-footer .name { font: 700 1.125rem var(--serif); color: var(--ink); margin: 0; }

/* ---- Paper ---- */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--hard-shadow);
  padding: var(--space);
}
.card > h2, .card > h3 { margin-bottom: 0.5rem; }

/* A torn bottom edge, at most once per page. The fill moves to a clipped layer so the hard shadow survives. */
.torn {
  position: relative;
  isolation: isolate;
  background: none;
  border: 0;
  box-shadow: none;
  filter: drop-shadow(3px 4px 0 var(--shadow));
  padding-bottom: calc(var(--space) + 0.5rem);
}
.torn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--paper);
  border: 1px solid var(--line);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 2px), 97.6% calc(100% - 3.2px), 95.3% calc(100% - 4.1px), 92.7% calc(100% - 4.3px), 89.5% calc(100% - 3.1px), 87.9% calc(100% - 3.8px), 85.4% calc(100% - 2.3px), 82.5% calc(100% - 2.7px), 80% calc(100% - 3.7px), 77% calc(100% - 2.5px), 74.8% calc(100% - 4.4px), 72.8% calc(100% - 1.9px), 70.3% calc(100% - 1.5px), 67.6% calc(100% - 1.2px), 64.5% calc(100% - 3.2px), 62.2% calc(100% - 1px), 60.5% calc(100% - 2.8px), 57.3% calc(100% - 2.9px), 55% calc(100% - 2px), 52.2% calc(100% - 2.8px), 50.2% calc(100% - 3px), 47.9% calc(100% - 1.2px), 44.9% calc(100% - 1px), 42.1% calc(100% - 0.9px), 39.8% calc(100% - 2.8px), 37% calc(100% - 3.3px), 34.8% calc(100% - 2.5px), 32.8% calc(100% - 3.2px), 29.8% calc(100% - 3.3px), 27.7% calc(100% - 2.2px), 25.5% calc(100% - 2.1px), 22.7% calc(100% - 4.5px), 19.5% calc(100% - 4.2px), 17.4% calc(100% - 3.3px), 14.5% calc(100% - 1.5px), 12.2% calc(100% - 4px), 9.7% calc(100% - 3.1px), 7.9% calc(100% - 3.4px), 4.8% calc(100% - 1.4px), 2.5% calc(100% - 2.5px), 0 calc(100% - 1px));
}

/* The exhibit frame: a thick yellow mat around a screenshot, pasted on slightly crooked. */
.print {
  margin: 0;
  width: var(--print-width, 17rem); /* definite, so an auto grid track doesn't size to the photo's 644 px */
  max-width: 100%;
  padding: clamp(0.5rem, 2vw, 0.8rem);
  background: var(--yellow);
  box-shadow: var(--hard-shadow);
  rotate: var(--tilt, 1.5deg);
}
.print img {
  display: block;
  width: 100%;
  aspect-ratio: 644 / 1400;
  background: var(--water);
  outline: 1px solid rgb(28 38 41 / 0.18);
  outline-offset: -1px;
}
.print figcaption { margin-top: 0.5rem; font: 600 0.8125rem/1.3 var(--mono); }
.prints { display: flex; justify-content: center; align-items: flex-start; gap: clamp(0.75rem, 3vw, 1.75rem); }
.prints .print { --print-width: 15rem; }
.prints .print:nth-child(2) { --tilt: -2deg; margin-top: 2.5rem; }

/* ---- Buttons ---- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.6rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-button);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--hard-shadow);
  font: 600 1rem/1.2 var(--sans);
  text-decoration: none;
}
.button:hover { background: #fff; }
.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.button.primary:hover { background: #173d52; }

/* ---- Home ---- */

.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(2.5rem, 6vw, 4rem); align-items: center; padding-block: clamp(1.5rem, 5vw, 3.5rem) 1rem; }
.hero-text { display: grid; gap: 1.5rem; justify-items: start; }
.hero .card { max-width: 34rem; }
.hero .lead { font-size: 1.1875rem; }
.hero .print { --print-width: 18rem; --tilt: 2deg; justify-self: center; }
@media (min-width: 52rem) {
  .hero { grid-template-columns: 1fr auto; }
  .hero .print { --print-width: 19rem; margin-right: 1.5rem; }
}

/* "Coming soon", inked on like the results rank stamp. */
.stamp {
  display: inline-block;
  margin: 0.25rem 0 1.25rem;
  padding: 0.55rem 1.1rem 0.6rem;
  border: 2.5px solid currentColor;
  border-radius: 6px;
  outline: 1px solid currentColor;
  outline-offset: -6px;
  color: var(--red);
  rotate: -6deg;
}
.stamp strong { font: 900 1.375rem/1.1 var(--serif); letter-spacing: 0.12em; text-transform: uppercase; }
@media (prefers-reduced-motion: no-preference) {
  .stamp { animation: stamp 0.35s 0.9s cubic-bezier(0.3, 1.6, 0.6, 1) both; }
}
@keyframes stamp { from { opacity: 0; scale: 1.4; } }

.section { margin-top: clamp(3.5rem, 9vw, 6.5rem); }
.section-head { display: grid; gap: 0.6rem; margin-bottom: 1.5rem; }
.section-head h2 { font-size: clamp(1.5rem, 4.5vw, 2rem); }
.section-head h2 .tape { padding-inline: 0.3em; }

.feature { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(2rem, 5vw, 3.5rem); align-items: center; }
.feature > .print { justify-self: center; }
@media (min-width: 52rem) {
  .feature { grid-template-columns: minmax(0, 1fr) auto; }
  .feature.flip { grid-template-columns: auto minmax(0, 1fr); }
  .feature.flip > :last-child { order: -1; }
  .feature > .prints { width: clamp(22rem, 40vw, 32rem); }
}

.maps { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); margin: 0; padding: 0; list-style: none; }
.maps li { padding: 1.1rem 1.25rem; }
.maps h3 { font-size: 1.25rem; }
.maps p { margin: 0.15rem 0 0; color: var(--muted); }

.modes { display: grid; gap: 1.5rem; }
.modes h3 { font: 600 0.8125rem/1.3 var(--mono); color: var(--muted); margin-bottom: 0.35rem; }
.modes dl { margin: 0; }
.modes dt { font: 700 1.125rem/1.3 var(--serif); margin-top: 0.6rem; }
.modes dd { margin: 0; color: var(--muted); }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 1rem; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 2rem 1fr; gap: 0.75rem; }
.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font: 700 0.9375rem var(--serif);
}
.quotes { margin: 1.25rem 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.quotes li { padding: 0.25rem 0.6rem; background: var(--surface); border: 1px solid var(--line); font: 600 0.875rem/1.4 var(--serif); font-style: italic; }

/* ---- Inner pages ---- */

.page-head { display: grid; gap: 1.75rem; justify-items: start; padding-block: clamp(1.5rem, 5vw, 3rem) 0.5rem; }
.prose { max-width: 44rem; }
.prose h3 { font-size: 1.125rem; margin: 1.5em 0 0.4em; }
.prose h3:first-child { margin-top: 0; }
.prose ul { margin: 0 0 1em; padding-left: 1.25rem; }
.prose li + li { margin-top: 0.35em; }

/* A list section, as in the app's settings: a taped mono header on the map, then paper. */
.list-section { margin-top: 2.25rem; max-width: 44rem; }
.list-section > h2 { margin-bottom: 0.6rem; font: 600 0.9375rem/1.85 var(--mono); }
.list-section .card { padding: clamp(1.1rem, 3.5vw, 1.6rem); }
.meta { color: var(--muted); font-size: 0.9375rem; }

/* FAQ: native details; the marker sits before the question and turns when it opens. */
.faq details { border-top: 1px solid var(--line); }
.faq details:first-child { border-top: 0; }
.faq summary {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding-block: 0.85rem;
  list-style: none;
  cursor: pointer;
  font: 700 1.0625rem/1.4 var(--serif);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: "";
  flex: none;
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  rotate: -45deg;
  translate: 0 -0.1em;
}
.faq details[open] > summary::before { rotate: 45deg; }
.faq summary:hover { color: var(--blue); }
.faq details > div { padding: 0 0 1rem 1.2rem; }
@media (prefers-reduced-motion: no-preference) {
  .faq summary::before { transition: rotate 0.2s; }
}

/* Placeholders the owner must fill before publishing. Loud on purpose. */
.todo {
  padding: 0.05em 0.35em;
  border: 1.5px dashed var(--red);
  background: #fff3cd;
  color: var(--ink);
  font: 600 0.875em var(--mono);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.todo::before { content: "TODO: "; color: var(--red); }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
