/* onceuponadeed.com - a storybook page in the game's own parchment, wood and wax colours (scenes/ui/theme/UiPalette.gd) */
@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("/fonts/atkinson.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Caveat"; src: url("/fonts/caveat.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --ink: #3B2A1E;          /* UiPalette INK */
  --ink-soft: #5C4633;
  --parchment: #F4E9D3;
  --parchment-shade: #E6D5B3;
  --cream: #FFF6E5;
  --wood: #4A2F1B;
  --wood-mid: #6E4A2C;
  --wax-red: #9E2B25;
  --stamp-red: #B3262E;    /* the title lockup's Deed stamp */
  --wax-green: #2E6A4E;
  --wax-blue: #2B4C7A;
  --gold: #F2C14E;
  --lamp-bg: #241B14;
  --lamp-text: #F1E4C8;
  --sky-top: #74C2CB;      /* sampled from the hero art's sky */
  --sky-low: #BFE4E2;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Atkinson Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--sans); font-size: 1.125rem; line-height: 1.65;
  background-color: var(--parchment);
  background-image:
    radial-gradient(ellipse at 15% 10%, rgba(255, 246, 229, .7), transparent 55%),
    radial-gradient(ellipse at 90% 60%, rgba(230, 213, 179, .55), transparent 60%);
  overflow-x: hidden; min-height: 100vh;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--wax-blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--wax-red); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; box-shadow: 0 0 0 6px var(--wood); }

.skip { position: absolute; left: -999px; top: 0; background: var(--wood); color: var(--cream); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; top: 1rem; }

.wrap { max-width: 1080px; margin: 0 auto; padding-inline: max(20px, env(safe-area-inset-left)) max(20px, env(safe-area-inset-right)); }
.narrow { max-width: 720px; }
section { padding-block: clamp(3rem, 7vw, 5.5rem); }
.center { text-align: center; }

h1, h2, h3 { font-family: var(--serif); font-weight: 650; line-height: 1.15; margin: 0 0 .8rem; text-wrap: balance; }
h1 { margin: 0; }
h2 { font-size: clamp(1.75rem, 4.2vw, 2.6rem); font-variation-settings: "opsz" 96, "SOFT" 100; }
h3 { font-size: clamp(1.35rem, 2.6vw, 1.7rem); font-variation-settings: "opsz" 48, "SOFT" 100; }
p { margin: 0 0 1rem; }
em { font-family: var(--serif); font-style: italic; }
.hand em { font-family: inherit; font-style: normal; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

/* "Chapter I" labels: italic serif in wax red between two small rules */
.chapter {
  font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 1.15rem; color: var(--wax-red);
  margin-bottom: .4rem; display: flex; align-items: center; gap: .6rem;
}
.chapter::before, .chapter::after { content: ""; height: 1px; width: 2rem; background: currentColor; opacity: .55; }
.chapter::after { display: none; }
.chapter.center { justify-content: center; }
.chapter.center::after { display: block; }

.status {
  display: inline-block; font-family: var(--serif); font-weight: 700; font-size: .95rem; letter-spacing: .04em;
  color: var(--cream); background: var(--wax-green); border-radius: 999px; padding: .45rem 1.1rem; margin: 0;
  box-shadow: inset 0 0 0 2px rgba(255, 246, 229, .35), 0 2px 0 rgba(59, 42, 30, .25);
  text-decoration: none;
}
a.status:hover { color: var(--cream); background: var(--wax-red); }

/* ---------- Hero: the sky, the title lettering, then the map floating below ---------- */
.hero {
  position: relative; text-align: center;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-low) 100%);
}
.hero-title { position: relative; z-index: 1; padding: clamp(1.5rem, 5vw, 3rem) 20px 0; }
.hero h1 img { width: min(560px, 92%); margin: 0 auto; filter: drop-shadow(0 6px 10px rgba(59, 42, 30, .25)); }
.tagline {
  font-family: var(--serif); font-style: italic; font-weight: 500; font-size: clamp(1.25rem, 3vw, 1.7rem);
  color: var(--wood); margin: .4rem 0 .9rem; text-shadow: 0 1px 0 rgba(255, 246, 229, .6);
}
.hero-art img {
  width: 100%; max-height: 560px; object-fit: cover; object-position: 50% 40%;
  margin-top: -1.5rem;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22%);
  mask-image: linear-gradient(180deg, transparent 0, #000 22%);
}
/* scalloped page edge where the sky meets the parchment */
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 18px;
  background: radial-gradient(circle at 12px 18px, var(--parchment) 11px, transparent 12px) 0 0 / 24px 18px repeat-x;
}

/* ---------- Opening: drop cap + the mentor's margin note ---------- */
.opening { padding-top: clamp(2.5rem, 6vw, 4rem); }
.dropcap { font-size: clamp(1.2rem, 2.3vw, 1.4rem); line-height: 1.6; }
.dropcap::first-letter {
  font-family: var(--serif); font-weight: 800; float: left; font-size: 4.3em; line-height: .82;
  margin: .06em .12em 0 0; color: var(--stamp-red); font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
}
.lede { font-family: var(--serif); font-style: italic; font-size: clamp(1.2rem, 2.4vw, 1.45rem); color: var(--wax-green); }
.margin-note {
  margin: 2rem 0 0; padding: 1rem 1.25rem; border-left: 4px solid var(--gold); background: rgba(255, 246, 229, .7);
  border-radius: 0 10px 10px 0;
}
.margin-note p { font-family: var(--hand); font-size: clamp(1.6rem, 3.6vw, 2rem); line-height: 1.25; margin: 0 0 .3rem; color: var(--wood); }
.margin-note footer { font-size: .95rem; color: var(--ink-soft); }
.margin-note footer::before { content: "\2014\00a0"; }

/* ---------- The letter ---------- */
.letter-sec { background: linear-gradient(180deg, transparent, rgba(46, 106, 78, .08) 30%, rgba(46, 106, 78, .08) 70%, transparent); }
.letter-grid { display: grid; gap: 2rem; align-items: center; }
.letter {
  position: relative; margin: 0; padding: 1.5rem 1.4rem 1.3rem; background: var(--cream);
  border: 1px solid var(--parchment-shade); border-radius: 6px; transform: rotate(-1deg);
  box-shadow: 0 1px 0 var(--parchment-shade), 0 14px 30px -12px rgba(59, 42, 30, .35);
  background-image: repeating-linear-gradient(180deg, transparent 0 2.05rem, rgba(43, 76, 122, .14) 2.05rem calc(2.05rem + 1px));
}
.letter .portrait {
  float: right; width: 120px; margin: -2.6rem -.6rem .4rem .8rem; border-radius: 50%;
  background: radial-gradient(circle, #FFF6E5 55%, #E6D5B3); border: 4px solid var(--cream);
  box-shadow: 0 0 0 2px var(--wood-mid), 0 6px 14px rgba(59, 42, 30, .3); aspect-ratio: 1; object-fit: cover; object-position: 50% 18%;
}
.letter .hand { margin: 0; }
.letter .hand p { font-family: var(--hand); font-size: clamp(1.45rem, 3.4vw, 1.75rem); line-height: 2.05rem; color: #2B2340; margin: 0; }
.letter figcaption { clear: both; margin-top: .9rem; font-size: .95rem; color: var(--ink-soft); font-style: italic; }
/* a little wax seal on the corner */
.letter::after {
  content: "D"; position: absolute; right: -8px; bottom: -14px; width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--serif); font-weight: 800; font-size: 1.6rem; color: var(--cream);
  background: radial-gradient(circle at 35% 30%, #C4453C, var(--wax-red) 60%, #7A1F1A);
  box-shadow: 0 3px 6px rgba(59, 42, 30, .4); transform: rotate(8deg);
}

/* ---------- Chapters ---------- */
.chapters h2 { margin-bottom: 2rem; }
.ch { display: grid; gap: 1.2rem; margin-bottom: clamp(2.5rem, 6vw, 4.5rem); align-items: center; }
.ch:last-child { margin-bottom: 0; }
.zoom { display: block; border-radius: 10px; overflow: hidden; border: 6px solid var(--cream);
  box-shadow: 0 0 0 1px var(--parchment-shade), 0 12px 26px -12px rgba(59, 42, 30, .45); transition: transform .2s ease; }
.zoom:hover { transform: translateY(-3px) rotate(-.4deg); }
.ch-text p:last-child { margin-bottom: 0; }
.leaves { list-style: none; padding: 0; margin: 0; }
.leaves li { position: relative; padding-left: 1.6rem; margin-bottom: .7rem; }
.leaves li::before {
  content: ""; position: absolute; left: 0; top: .5em; width: .75rem; height: .75rem;
  background: var(--wax-green); border-radius: 0 70% 0 70%; transform: rotate(-10deg);
}

/* ---------- Gallery ---------- */
.gallery { list-style: none; padding: 0; margin: 1.5rem 0 1rem; display: grid; gap: 1rem; }
.gallery li:nth-child(2) .zoom { transform: rotate(.6deg); }
.gallery li:nth-child(3) .zoom { transform: rotate(-.5deg); }
.gallery .zoom:hover { transform: translateY(-3px); }

/* ---------- Listing-speak decoder ---------- */
.decoder { background: rgba(230, 213, 179, .45); }
.ledger { margin: 1.4rem 0 0; padding: 1rem 1.2rem; background: var(--cream); border: 2px solid var(--wood-mid); border-radius: 8px;
  box-shadow: 4px 4px 0 var(--parchment-shade); }
.ledger div { display: grid; gap: .1rem; padding: .6rem 0; border-bottom: 1px dashed var(--parchment-shade); }
.ledger div:last-child { border-bottom: 0; }
.ledger dt { font-family: var(--serif); font-weight: 650; color: var(--wax-blue); }
.ledger dd { margin: 0; font-family: var(--hand); font-size: 1.5rem; line-height: 1.2; color: var(--wax-red); }

/* ---------- Cozy promises: a sealed charter ---------- */
.charter {
  position: relative; background: var(--cream); border: 2px solid var(--wood-mid); border-radius: 12px;
  padding: clamp(1.5rem, 4vw, 2.5rem); box-shadow: inset 0 0 0 6px var(--cream), inset 0 0 0 7px var(--parchment-shade);
}
.seals { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .9rem; }
.seals li { position: relative; padding-left: 2.6rem; min-height: 2rem; }
.seals li::before {
  content: "\2713"; position: absolute; left: 0; top: -.05rem; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 1rem; color: var(--cream);
  background: radial-gradient(circle at 35% 30%, #C4453C, var(--wax-red) 60%, #7A1F1A); box-shadow: 0 2px 3px rgba(59, 42, 30, .35);
}

/* ---------- 404 ---------- */
.page404 { min-height: min(70vh, 640px); display: flex; align-items: center; padding-block: 4rem; }
.back { margin-top: 1.6rem; }
.mini-logo { width: 220px; margin-bottom: 1.6rem; }

/* ---------- Early Access ---------- */
.ea { padding-bottom: clamp(3.5rem, 8vw, 6rem); }

/* ---------- Footer: lamplight on dark wood ---------- */
.foot { background: var(--lamp-bg); color: var(--lamp-text); padding-block: 3rem calc(3rem + env(safe-area-inset-bottom)); font-size: 1rem; }
.foot a { color: var(--gold); }
.foot a:hover { color: var(--cream); }
.studio-logo { display: inline-block; margin-bottom: 1rem; }
.studio-logo img { width: 220px; }
.studio { font-family: var(--serif); font-size: 1.2rem; margin-bottom: .4rem; }
.foot details { border-top: 1px solid rgba(241, 228, 200, .2); padding: .8rem 0; }
.foot details:last-of-type { border-bottom: 1px solid rgba(241, 228, 200, .2); margin-bottom: 1.2rem; }
.foot summary { cursor: pointer; font-weight: 700; }
.foot details p { margin: .7rem 0 0; color: #E2D3B4; }
.fine { font-size: .9rem; color: var(--ink-soft); }
.foot .fine { color: #CDBB98; margin-bottom: .4rem; }

/* ---------- Screenshot viewer ---------- */
dialog { border: 0; padding: 0; background: transparent; max-width: min(96vw, 1600px); width: 100%; }
dialog::backdrop { background: rgba(36, 27, 20, .9); }
dialog img { width: 100%; border-radius: 8px; border: 6px solid var(--cream); }
dialog .close {
  position: absolute; top: .5rem; right: .5rem; width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 0;
  background: var(--wax-red); color: var(--cream); font-size: 1.6rem; line-height: 1; cursor: pointer;
}

/* ---------- Wider screens ---------- */
@media (min-width: 720px) {
  .gallery { grid-template-columns: repeat(3, 1fr); }
  .ledger div { grid-template-columns: 15rem 1fr; align-items: baseline; gap: 1rem; }
  .letter { padding: 2rem 2rem 1.6rem; }
  .letter .portrait { width: 150px; }
}
@media (min-width: 880px) {
  .letter-grid { grid-template-columns: 5fr 6fr; gap: 3rem; }
  .ch { grid-template-columns: 7fr 5fr; gap: 2.5rem; }
  .ch.flip { grid-template-columns: 5fr 7fr; }
  .ch.flip .zoom { order: 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .zoom:hover, .gallery .zoom:hover { transform: none; }
}
