/* ==========================================================================
   The Tideline Chronicles — global stylesheet
   Franchise-site layout (sticky nav, poster shelf, character tiles)
   in the daylight-beach palette of the Book 1 cover.
   ========================================================================== */

:root {
  --sky-top:    #8ecfec;
  --sky:        #c2e7f6;
  --sea:        #1e9ab5;
  --sea-deep:   #0b6e8c;
  --abyss:      #083f54;
  --sand:       #f6e8c9;
  --sand-2:     #efdcb0;
  --foam:       #fdf9ef;
  --gold:       #f5b942;
  --gold-soft:  #ffd97a;
  --ink:        #143247;
  --text:       #2e4356;
  --white:      #ffffff;
  --rust:       #8c4a2f;   /* Jack's coat */
  --palm:       #3e8a5a;
  --bread:      #d99a3d;
  --radius:     14px;
  --nav-h:      62px;
  --font-display: "Baloo 2", "Trebuchet MS", sans-serif;
  --font-body: Georgia, "Times New Roman", serif;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.06rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--foam);
}

img, svg { max-width: 100%; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 22px; }
.container.narrow { max-width: 720px; }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; margin: 0 0 0.5em; }
h2 { font-size: clamp(1.8rem, 4.4vw, 2.6rem); font-weight: 800; color: var(--ink); }
h3 { font-size: 1.18rem; }
p  { margin: 0 0 1em; }

section[id], header[id] { scroll-margin-top: calc(var(--nav-h) + 8px); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============ NAV ============ */

.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: rgba(253,249,239,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(8,63,84,0.12);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: var(--nav-h); }

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.08rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand-anchor { color: var(--sea-deep); margin-right: 2px; }

.nav-links {
  display: flex; align-items: center; gap: 4px;
  list-style: none; margin: 0; padding: 0;
}
.nav-links a:not(.btn) {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  text-decoration: none;
  padding: 8px 13px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-links a:not(.btn):hover { background: rgba(30,154,181,0.12); }
.nav-links a.active { background: var(--sea-deep); color: var(--white); }

.btn-nav { padding: 9px 18px; font-size: 0.95rem; animation: none; margin-left: 8px; }

.nav-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 10px;
}
.nav-toggle span {
  display: block; width: 24px; height: 3px; border-radius: 2px;
  background: var(--ink); margin: 5px 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav.open .nav-toggle span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.nav.open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav.open .nav-toggle span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--foam);
    box-shadow: 0 12px 20px rgba(8,63,84,0.18);
    padding: 8px 16px 16px;
    display: none;
  }
  .nav.open .nav-links { display: flex; }
  .nav-links a:not(.btn) { padding: 13px 14px; border-radius: 10px; }
  .btn-nav { margin: 10px 0 0; text-align: center; }
}

/* ============ HERO — full-bleed series artwork ============ */

.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: min(720px, 92vh);
  color: var(--foam);
  padding: 90px 0 130px;
  text-align: center;
  background:
    radial-gradient(ellipse 46% 34% at 78% 4%, rgba(255,236,170,0.85), rgba(255,236,170,0) 70%),
    radial-gradient(ellipse 95% 42% at 50% 106%, rgba(255,217,122,0.75), rgba(245,185,66,0) 62%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky) 38%, #6fc4d8 62%, var(--sea) 82%, var(--sea-deep) 100%);
}

.hero-bg {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 35%;
}

/* readability veil over the artwork: gentle at top, stronger where the text sits */
.hero-shade {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg,
    rgba(8,63,84,0.10) 0%,
    rgba(8,63,84,0.30) 45%,
    rgba(8,63,84,0.62) 100%);
}

/* fallback mode: no hero art yet → CSS sky/sea scene, dark text */
.hero.no-art { color: var(--ink); }
.hero.no-art .hero-shade { display: none; }
.hero .clouds { display: none; }
.hero.no-art .clouds { display: block; }

.clouds {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.9;
  background-image:
    radial-gradient(ellipse 190px 52px at 16% 14%, rgba(255,255,255,0.95), rgba(255,255,255,0) 70%),
    radial-gradient(ellipse 240px 60px at 30% 22%, rgba(255,255,255,0.8),  rgba(255,255,255,0) 70%),
    radial-gradient(ellipse 200px 50px at 72% 12%, rgba(255,255,255,0.85), rgba(255,255,255,0) 70%),
    radial-gradient(ellipse 260px 64px at 88% 24%, rgba(255,255,255,0.7),  rgba(255,255,255,0) 70%);
  animation: drift 70s linear infinite alternate;
}
@keyframes drift { from { transform: translateX(-2%); } to { transform: translateX(2%); } }

.sparkles {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 18% 34%, rgba(255,217,122,0.95), transparent 60%),
    radial-gradient(1.5px 1.5px at 34% 18%, rgba(255,255,255,0.9), transparent 60%),
    radial-gradient(2px 2px at 47% 42%, rgba(255,217,122,0.85), transparent 60%),
    radial-gradient(1.5px 1.5px at 63% 28%, rgba(255,255,255,0.85), transparent 60%),
    radial-gradient(2.5px 2.5px at 76% 46%, rgba(255,217,122,0.9), transparent 60%),
    radial-gradient(1.5px 1.5px at 88% 36%, rgba(255,255,255,0.8), transparent 60%),
    radial-gradient(2px 2px at 9% 52%,  rgba(255,217,122,0.8), transparent 60%),
    radial-gradient(2px 2px at 55% 60%, rgba(255,236,170,0.9), transparent 60%);
  animation: twinkle 3.4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.35; } to { opacity: 1; } }

.hero-inner {
  position: relative; z-index: 3;
  max-width: 760px;
}

.hero-kicker {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: var(--gold-soft);
  text-shadow: 0 1px 6px rgba(8,63,84,0.6);
  margin-bottom: 10px;
}
.hero.no-art .hero-kicker { color: #a5651c; text-shadow: none; }

.hero-title {
  font-size: clamp(2.5rem, 7vw, 4.4rem);
  font-weight: 800;
  color: var(--white);
  text-shadow: 0 0 30px rgba(255,217,122,0.75), 0 3px 10px rgba(8,63,84,0.65);
  margin-bottom: 0.25em;
}
.hero.no-art .hero-title {
  color: var(--ink);
  text-shadow: 0 0 26px rgba(255,217,122,0.9), 0 2px 0 rgba(255,255,255,0.6);
}

.hero-tag {
  font-size: clamp(1.05rem, 2.4vw, 1.28rem);
  font-style: italic;
  color: var(--foam);
  text-shadow: 0 1px 8px rgba(8,63,84,0.7);
  margin-bottom: 0.8em;
}
.hero.no-art .hero-tag { color: #1d4257; text-shadow: none; }

.hero-blurb {
  font-size: 1.02rem;
  max-width: 58ch;
  margin: 0 auto 1.6em;
  text-shadow: 0 1px 8px rgba(8,63,84,0.7);
}
.hero.no-art .hero-blurb { color: var(--ink); text-shadow: none; }

.hero .signup { margin: 0 auto; }
.hero .signup-row { justify-content: center; }
.hero .signup-fine { text-shadow: 0 1px 6px rgba(8,63,84,0.7); opacity: 0.95; }
.hero.no-art .signup-fine { text-shadow: none; opacity: 0.75; }
.hero .signup-msg.ok  { color: var(--gold-soft); }
.hero.no-art .signup-msg.ok { color: #0b6e3a; }

.divider-hero {
  position: absolute; left: 0; right: 0; bottom: -2px;
  display: block; width: 100%; height: 64px;
  fill: var(--foam);
}

/* ============ SIGNUP FORM ============ */

.signup { max-width: 560px; }

.signup-lead { font-size: 1.02rem; color: var(--ink); margin-bottom: 1em; }

.signup-row { display: flex; gap: 10px; flex-wrap: wrap; }

.signup input[type="email"] {
  flex: 1 1 240px;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid rgba(11,110,140,0.35);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  outline: none;
}
.signup input[type="email"]:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,185,66,0.4); }

.btn {
  display: inline-block;
  padding: 14px 26px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  color: #4a2c05;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: none;
  border-radius: 999px;              /* franchise-site pill buttons */
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(245,185,66,0.55);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  animation: beckon 3.2s ease-in-out infinite;
}
@keyframes beckon {
  0%, 100% { box-shadow: 0 4px 16px rgba(245,185,66,0.45); }
  50%      { box-shadow: 0 4px 26px rgba(245,185,66,0.85); }
}
.btn:hover  { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.signup-fine { font-size: 0.8rem; opacity: 0.75; margin-top: 0.9em; }

.signup-msg { font-family: var(--font-display); font-weight: 600; font-size: 1rem; min-height: 1.4em; margin-top: 0.4em; }
.signup-msg.ok  { color: #0b6e3a; }
.signup-msg.err { color: #b3401e; }
.signup-dark .signup-msg.ok { color: var(--gold-soft); }
.signup-dark .signup-msg.err { color: #ffab8a; }
.signup.sent .signup-row, .signup.sent .signup-fine, .signup.sent .signup-lead { display: none; }
.signup.sent .signup-msg { font-size: 1.15rem; }

.honeypot { position: absolute; left: -9999px; opacity: 0; height: 0; width: 0; }

/* ============ SECTIONS ============ */

.section { padding: 74px 0; }

.story { background: var(--foam); text-align: center; }
.story h2 { margin-bottom: 0.8em; }
.story-hook {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.12rem;
  color: var(--sea-deep);
  margin-top: 1.4em;
}

/* The three objects */
.objects-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 20px;
  margin-top: 44px;
}
.object-card { margin: 0; text-align: center; }
.obj-art {
  position: relative;
  width: 130px; height: 130px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 38% 32%, #ffedbe, var(--sand-2) 70%);
  box-shadow: 0 6px 16px rgba(8,63,84,0.15), inset 0 0 0 4px rgba(255,255,255,0.6);
  overflow: hidden;
}
.obj-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.obj-fallback { width: 58px; height: 58px; color: var(--sea-deep); }
.object-card h3 { color: var(--ink); margin-bottom: 0.2em; }
.object-card p { font-size: 0.92rem; margin: 0 auto; max-width: 26ch; }

/* Wide chapter-art bands between sections (auto-remove if image missing) */
.art-band { line-height: 0; background: var(--abyss); }
.art-band img { width: 100%; height: clamp(140px, 22vw, 300px); object-fit: cover; display: block; }

/* ============ BOOKS — the poster shelf ============ */

.books {
  text-align: center;
  background:
    radial-gradient(ellipse 80% 45% at 50% -5%, rgba(255,236,170,0.5), rgba(255,236,170,0) 60%),
    linear-gradient(180deg, var(--sand) 0%, var(--sand-2) 100%);
}
.books-sub { max-width: 620px; margin: 0 auto 8px; }

.shelf-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; padding: 30px 0 18px; }
.shelf {
  list-style: none;
  display: flex;
  gap: 20px;
  margin: 0;
  padding: 6px max(22px, calc((100vw - 1080px) / 2 + 22px));
  scroll-snap-type: x proximity;
  width: max-content;
}

.poster {
  position: relative;
  flex: 0 0 auto;
  width: 176px;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  scroll-snap-align: center;
  background: linear-gradient(165deg, var(--sea) 0%, var(--sea-deep) 60%, var(--abyss) 100%);
  box-shadow: 0 0 0 5px var(--white), 0 10px 22px rgba(8,63,84,0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.poster:nth-child(odd)  { transform: rotate(-2deg); }
.poster:nth-child(even) { transform: rotate(2deg); }
.poster:hover {
  transform: rotate(0) translateY(-8px) scale(1.04);
  box-shadow: 0 0 0 5px var(--white), 0 18px 30px rgba(8,63,84,0.45);
  z-index: 2;
}

.poster img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* placeholder card shown until real cover art is dropped into assets/ */
.p-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  padding: 14px;
  color: var(--foam);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.25;
  text-align: center;
}
.p-fallback b {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--gold);
  color: #4a2c05;
  font-size: 1.3rem;
  font-weight: 800;
}

.shelf-hint {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--sea-deep);
  opacity: 0.7;
  text-align: center;
  margin: 0;
}

/* Buy links: injected by script.js only when a book's URLs exist in the BOOKS config */
.poster-cta {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 6px; justify-content: center;
  padding: 26px 8px 9px;
  background: linear-gradient(0deg, rgba(8,63,84,0.92) 30%, rgba(8,63,84,0));
}
.poster-cta a {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: #4a2c05;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
}
.poster-cta a.alt { background: rgba(255,255,255,0.92); color: var(--ink); }
.poster-cta a:hover { transform: translateY(-1px); }

/* ============ WHAT YOU GET (the loot) ============ */

.loot { background: var(--foam); text-align: center; padding-bottom: 84px; }
.loot-sub { max-width: 560px; margin: 0 auto; }
.loot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
  margin-top: 34px;
  text-align: left;
}
.loot-card {
  margin: 0;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(8,63,84,0.12);
  border-top: 4px solid var(--gold);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.loot-card:hover { transform: translateY(-5px); box-shadow: 0 10px 24px rgba(8,63,84,0.18); }
.loot-art {
  position: relative;
  aspect-ratio: 16 / 10;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #d8f0f7, #9fd3e4);
}
.loot-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.loot-fallback { width: 54px; height: 54px; color: var(--sea-deep); }
.loot-card figcaption { padding: 20px 22px 22px; }
.loot-card h3 { color: var(--ink); margin-bottom: 0.35em; }
.loot-card p { font-size: 0.96rem; margin: 0; }

/* ============ MID JOIN BAND ============ */

.join-band {
  text-align: center;
  color: var(--foam);
  padding: 64px 0;
  background:
    radial-gradient(ellipse 85% 70% at 50% 120%, rgba(255,217,122,0.5), rgba(245,185,66,0) 62%),
    linear-gradient(180deg, var(--sea) 0%, var(--sea-deep) 100%);
}
.join-band h2 { color: var(--white); text-shadow: 0 0 22px rgba(255,217,122,0.45); }
.band-sub { opacity: 0.94; margin-bottom: 1.6em; }
.join-band .signup { margin: 0 auto; }
.join-band .signup-row { justify-content: center; }

/* ============ CREW — character tiles ============ */

.crew { background: var(--foam); text-align: center; }
.crew-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px;
  margin-top: 32px;
  text-align: center;
}

.crew-tile { margin: 0; }
.tile-art {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(8,63,84,0.18);
  transition: transform 0.15s ease;
}
.crew-tile:hover .tile-art { transform: translateY(-6px) rotate(-1deg); }
.tile-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile-letter {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 4.4rem;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 3px 0 rgba(0,0,0,0.15);
}

.tile-gold  .tile-art { background: linear-gradient(160deg, var(--gold-soft), var(--gold)); }
.tile-teal  .tile-art { background: linear-gradient(160deg, #3fb4c8, var(--sea-deep)); }
.tile-rust  .tile-art { background: linear-gradient(160deg, #b06a45, var(--rust)); }
.tile-navy  .tile-art { background: linear-gradient(160deg, #2d5a77, var(--ink)); }
.tile-bread .tile-art { background: linear-gradient(160deg, #ecc27a, var(--bread)); }
.tile-palm  .tile-art { background: linear-gradient(160deg, #63b585, var(--palm)); }
.tile-stone .tile-art { background: linear-gradient(160deg, #8fa3ad, #5b7280); }
.tile-parch .tile-art { background: linear-gradient(160deg, #d8c493, #b09a63); }
.tile-coral .tile-art { background: linear-gradient(160deg, #f19a8e, #e2705d); }
.tile-sky   .tile-art { background: linear-gradient(160deg, #9ed6ee, #5aa8cc); }
.tile-wool  .tile-art { background: linear-gradient(160deg, #b8c3cf, #7f8fa0); }
.tile-shell .tile-art { background: linear-gradient(160deg, #f3d9c4, #d9ab8a); }
.tile-tern  .tile-art { background: linear-gradient(160deg, #4fae83, #2c7a58); }
.tile-moss  .tile-art { background: linear-gradient(160deg, #a8b86b, #7a8b45); }
.tile-inkwell .tile-art { background: linear-gradient(160deg, #6f6a95, #46425f); }
.tile-storm .tile-art { background: linear-gradient(160deg, #6b7480, #39414c); }

.cast-heading { margin-top: 64px; }

.crew-tile h3 { margin: 14px 0 4px; color: var(--ink); }
.crew-tile p { font-size: 0.93rem; margin: 0 auto; max-width: 30ch; }

/* ============ PARENTS ============ */

.parents { background: var(--sand); }
.parents h2 { text-align: center; margin-bottom: 1em; }

/* ============ FINAL CTA ============ */

.final-cta {
  text-align: center;
  color: var(--foam);
  background:
    radial-gradient(ellipse 85% 60% at 50% 115%, rgba(255,217,122,0.55), rgba(245,185,66,0) 62%),
    linear-gradient(180deg, var(--sea) 0%, var(--sea-deep) 55%, var(--abyss) 100%);
}
.final-cta h2 { color: var(--white); text-shadow: 0 0 24px rgba(255,217,122,0.5); }
.final-sub { opacity: 0.94; margin-bottom: 1.6em; }
.final-cta .signup { margin: 0 auto; }
.final-cta .signup-row { justify-content: center; }

/* ============ FOOTER ============ */

.footer {
  background: var(--abyss);
  color: rgba(253,249,239,0.75);
  text-align: center;
  padding: 30px 0;
  font-size: 0.85rem;
}
.footer p { margin: 0 0 4px; }
.footer-fine { opacity: 0.6; }

/* ============ RESPONSIVE / MOTION ============ */

@media (max-width: 840px) {
  .hero { min-height: min(620px, 88vh); }
  .signup { margin: 0 auto; }
  .signup-row { justify-content: center; }
}

@media (max-width: 520px) {
  .section { padding: 54px 0; }
  .hero { padding-top: 40px; }
  .signup-row { flex-direction: column; }
  .btn { width: 100%; }
  .poster { width: 148px; }
}

@media (prefers-reduced-motion: reduce) {
  .ship, .hero-cover img, .clouds, .sparkles, .btn { animation: none; }
  html { scroll-behavior: auto; }
  .btn, .poster, .tile-art, .nav-links a { transition: none; }
}
