/* Antigua Marina: prelude cards and chapter screen.
   Type is IM Fell English, a revival of seventeenth-century English printing types. */
@font-face {
  font-family: "IM Fell English";
  src: url("/fonts/im-fell-english-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IM Fell English";
  src: url("/fonts/im-fell-english-latin-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "IM Fell English SC";
  src: url("/fonts/im-fell-english-sc-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

/* The Fell types draw 1 like a capital I and 0 like a small o, which makes
   years hard to read, so numerals are borrowed from a plainer serif. */
@font-face {
  font-family: "AM Numerals";
  src: local("Times New Roman"), local("Times"), local("Liberation Serif"), local("Noto Serif");
  unicode-range: U+30-39;
}

:root {
  --period: "AM Numerals", "IM Fell English", Georgia, "Times New Roman", serif;
  --period-caps: "AM Numerals", "IM Fell English SC", "IM Fell English", Georgia, serif;
  --brass-light: #e6c877;
}
.start { font-family: var(--period-caps); font-weight: 400; cursor: pointer; }
[hidden] { display: none !important; }
body.in-prelude, body.in-chapter { background: var(--navy-deep); overflow: hidden; }

/* ---------- Prelude ---------- */
.prelude {
  position: fixed;
  inset: 0;
  overflow: hidden;
  color: var(--cream);
  font-family: var(--period);
}
.card-art {
  position: absolute;
  inset: 0;
  background: var(--navy-deep) center / cover no-repeat;
  opacity: 0;
  transition: opacity 1.4s ease;
}
/* A slow, slight zoom. It grows from the top edge so nothing at the top of
   the picture is ever pushed off screen. */
.card-art { transform-origin: 50% 0%; }
.card-art.is-on { opacity: 1; }
/* The zoom keeps running on a picture while it fades out, so it never snaps back. */
.card-art.is-moving { animation: drift 26s ease-out both; }
@keyframes drift { from { transform: scale(1); } to { transform: scale(1.06); } }
/* Backdrop for a card whose artwork has not arrived yet. */
.card-art.is-blank {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 22vh;
  background: radial-gradient(ellipse at 50% 38%, #24486b 0%, #14283d 48%, #0b1826 100%);
  font-family: var(--period-caps);
  font-size: min(38vh, 46vw);
  line-height: 1;
  color: rgba(201, 162, 75, 0.13);
}
/* Darkens the lower part of the picture so the caption stays readable. */
.card-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(6, 14, 24, 0.55) 0%, rgba(6, 14, 24, 0) 16%),
    linear-gradient(to top, rgba(6, 14, 24, 0.82) 0%, rgba(6, 14, 24, 0.35) 38%, rgba(6, 14, 24, 0) 60%);
  pointer-events: none;
}

.card-top {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-count {
  margin: 0;
  font-family: var(--period-caps);
  font-size: 1rem;
  letter-spacing: 0.14em;
  color: rgba(241, 227, 196, 0.8);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.card-tools { display: flex; gap: 6px; }
/* Small, quiet text buttons: skip, sound, and the links on the chapter screen. */
.tool {
  padding: 6px 12px;
  font-family: var(--period);
  font-style: italic;
  font-size: 1rem;
  color: rgba(241, 227, 196, 0.72);
  background: rgba(11, 24, 38, 0.35);
  border: 1px solid rgba(201, 162, 75, 0.28);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.tool:hover, .tool:focus-visible {
  color: var(--cream);
  background: rgba(11, 24, 38, 0.75);
  border-color: var(--brass);
}
.tool:focus-visible, .next:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }

/* The caption plaque: navy board, brass rule, cream lettering, as on the logo. */
.card-panel {
  position: absolute;
  left: 50%;
  bottom: max(3.5vh, env(safe-area-inset-bottom));
  width: min(72rem, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: clamp(16px, 2.6vh, 28px) clamp(18px, 3vw, 40px) clamp(12px, 2vh, 20px);
  text-align: center;
  background: linear-gradient(rgba(27, 53, 82, 0.9), rgba(13, 28, 45, 0.94));
  border: 2px solid var(--brass);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 4px rgba(11, 24, 38, 0.9),
    inset 0 0 0 5px rgba(201, 162, 75, 0.45),
    0 14px 40px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.3s ease;      /* quick fade out; the text changes while it is hidden */
}
.card-panel.is-on { opacity: 1; transition: opacity 0.7s ease; }
.card-title {
  margin: 0;
  font-family: var(--period-caps);
  font-weight: 400;
  font-size: clamp(1.5rem, 3.6vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: 0.04em;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}
.card-year, .card-subtitle {
  display: block;
  font-family: var(--period);
  font-style: italic;
  letter-spacing: 0.06em;
  color: var(--brass-light);
}
.card-year { font-size: 0.62em; margin-bottom: 0.1em; }
.card-subtitle { font-size: 0.6em; margin-top: 0.25em; }
.card-title::after {
  content: "";
  display: block;
  width: min(220px, 50%);
  height: 1px;
  margin: 0.45em auto 0;
  background: linear-gradient(90deg, transparent, var(--brass), transparent);
}
.card-caption { margin-top: clamp(8px, 1.6vh, 16px); }
.card-caption p {
  margin: 0 auto;
  max-width: 52em;
  font-size: clamp(1.1rem, 2.1vw, 1.5rem);
  line-height: 1.4;
  text-wrap: pretty;
}
.card-caption p + p { margin-top: 0.4em; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 46px;
  margin-top: clamp(8px, 1.6vh, 16px);
}
.pips { display: flex; gap: 7px; margin: 0; padding: 0; list-style: none; }
.pips li {
  width: 9px; height: 9px;
  transform: rotate(45deg);
  border: 1px solid rgba(201, 162, 75, 0.7);
  background: transparent;
}
.pips li.is-done { background: rgba(201, 162, 75, 0.55); }
.pips li.is-now { background: var(--cream); border-color: var(--cream); }
.next {
  padding: 0.3em 1.5em 0.36em;
  font-family: var(--period-caps);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  color: var(--navy-deep);
  background: linear-gradient(#ecd08a, #c39a44);
  border: 1px solid #f3dea6;
  border-radius: 7px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease, filter 0.15s ease;
}
.next.is-on { opacity: 1; visibility: visible; }
.next:hover { filter: brightness(1.1); }

/* ---------- Chapter placeholder ---------- */
.chapter {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  color: var(--cream);
  font-family: var(--period);
  background: radial-gradient(ellipse at 50% 35%, #1d3a57 0%, var(--navy) 45%, var(--navy-deep) 100%);
  animation: rise 1s ease both;
}
@keyframes rise { from { opacity: 0; } to { opacity: 1; } }
.chapter .eyebrow { font-family: var(--period-caps); font-size: 1.05rem; }
.chapter .status { font-family: var(--period-caps); font-size: 1rem; }
.chapter-title {
  margin: 0;
  font-family: var(--period-caps);
  font-weight: 400;
  font-size: clamp(2.4rem, 8vw, 4.6rem);
  line-height: 1.05;
}
.chapter-sub { margin: 0.4em 0 0; font-style: italic; font-size: clamp(1.2rem, 3vw, 1.7rem); color: var(--brass-light); }
.chapter-links { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 28px 0 0; }

/* Tall screens (phones and tablets held upright): the pictures are square, so
   show the whole picture at the top and set the caption beneath it. */
@media (max-aspect-ratio: 1/1) {
  .card-art { bottom: auto; height: min(100vw, 64vh); height: min(100vw, 64dvh); background-position: 50% 50% !important; }
  .card-art.is-blank { padding-bottom: 0; font-size: min(30vh, 46vw); }
  .card-shade {
    background:
      linear-gradient(to bottom, rgba(6, 14, 24, 0.55) 0%, rgba(6, 14, 24, 0) 14%),
      linear-gradient(to bottom, rgba(11, 24, 38, 0) calc(min(100vw, 64dvh) - 90px), var(--navy-deep) min(100vw, 64dvh));
  }
}

/* Short or narrow screens: tighten the plaque so it never crowds the picture. */
@media (max-width: 560px) {
  .card-count { font-size: 0.85rem; }
  .tool { font-size: 0.92rem; padding: 5px 9px; }
  .pips li { width: 7px; height: 7px; }
  .pips { gap: 5px; }
}
/* Short, wide screens (a phone on its side): whole picture on the left,
   caption beside it, so the plaque never covers the scene. */
@media (min-aspect-ratio: 1/1) and (max-height: 520px) {
  .card-art { right: auto; width: 100vh; width: 100dvh; background-position: 50% 50% !important; }
  .card-art.is-blank { padding-bottom: 0; font-size: 46vh; }
  .card-shade {
    background: linear-gradient(to right, rgba(11, 24, 38, 0) calc(100dvh - 70px), var(--navy-deep) 100dvh);
  }
  .card-panel {
    left: calc(100dvh + 8px);
    width: calc(100vw - 100dvh - 20px - env(safe-area-inset-right));
    top: 54%;
    bottom: auto;
    padding: 12px 16px 10px;
    transform: translateY(-50%);
  }
  .card-title { font-size: clamp(1.15rem, 5.4vh, 1.6rem); }
  .card-caption p { font-size: clamp(0.95rem, 4.4vh, 1.15rem); line-height: 1.3; }
  .card-foot { min-height: 38px; margin-top: 8px; }
  .card-count { font-size: 0.85rem; }
  .tool { font-size: 0.9rem; padding: 4px 9px; }
  .pips { gap: 4px; }
  .pips li { width: 6px; height: 6px; }
  .next { padding: 0.25em 0.9em 0.3em; letter-spacing: 0.1em; text-indent: 0.1em; }
}
@media (prefers-reduced-motion: reduce) {
  .card-art.is-moving { animation: none; }
  .card-art, .card-panel, .next { transition-duration: 0.01s; }
  .chapter { animation: none; }
}

/* The About link on the title screen: a small plaque in the corner. */
.tool.about-link {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(2.5vh, 14px, env(safe-area-inset-bottom));
  padding: 0.35em 1.1em 0.4em;
  font-family: var(--period-caps);
  font-style: normal;
  font-size: clamp(1rem, 2.2vh, 1.25rem);
  letter-spacing: 0.12em;
  text-decoration: none;
  color: var(--cream);
  background: linear-gradient(rgba(31, 61, 92, 0.92), rgba(18, 38, 59, 0.94));
  border: 2px solid var(--brass);
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}
.tool.about-link:hover, .tool.about-link:focus-visible { filter: brightness(1.2); }
/* Upright screens: Start is centred at the bottom, so About goes to the top corner. */
@media (max-aspect-ratio: 5/4) {
  .tool.about-link { bottom: auto; top: max(14px, env(safe-area-inset-top)); }
}
