/* --------------------------------------------------------------------------
   ΟΔΥΣΣΕΙΑ
   Type: Cinzel (Roman inscriptional) against Cormorant Garamond.
   Palette: bronze / oil-lamp gold on deep sea-ink.
   -------------------------------------------------------------------------- */

:root{
  --gold:   #d8b169;
  --gold-2: #f0d9a6;
  --bronze: #a5763c;
  --ink:    #06070d;
  --paper:  #f3e9d5;
  --muted:  #cbbfa6;
  --edge:   rgba(216,177,105,.34);
  --serif:  'Cormorant Garamond', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --roman:  'Cinzel', 'Trajan Pro', Georgia, serif;
}

*{ box-sizing: border-box; }

html{ scroll-behavior: smooth; background: var(--ink); }
html.locked{ overflow: hidden; }

body{
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---- the living background ---------------------------------------------- */
#gl{
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  z-index: 0;
}
body.nogl #gl{ display: none; }

/* readability scrim; sits between canvas and type */
.scrim{
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 110%, rgba(3,4,9,.60), transparent 62%),
    radial-gradient(120% 70% at 50% -10%, rgba(3,4,9,.50), transparent 60%);
}

#scroller{ position: relative; z-index: 0; }

/* ---- chapters ------------------------------------------------------------ */
#stage{
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.chapter{
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  will-change: opacity, transform;
}
.chapter.is-left  { justify-content: flex-start; }
.chapter.is-right { justify-content: flex-end; }

/* Directional scrim across the whole viewport — no box edges anywhere,
   just a side of the image sinking into shadow so the type can sit on it.
   It extends far beyond the viewport top and bottom so the vertical drift
   of the panel while scrolling can never expose its edge: it only ever
   fades in and out with the chapter. */
.chapter::before{
  content: '';
  position: absolute;
  top: -60vh;
  bottom: -60vh;
  left: 0;
  right: 0;
  z-index: -1;
  pointer-events: none;
}
.chapter.is-left::before{
  background: linear-gradient(90deg,
    rgba(4,5,11,.86) 0%, rgba(4,5,11,.72) 22%, rgba(4,5,11,.40) 45%,
    rgba(4,5,11,.12) 62%, transparent 76%);
}
.chapter.is-right::before{
  background: linear-gradient(270deg,
    rgba(4,5,11,.86) 0%, rgba(4,5,11,.72) 22%, rgba(4,5,11,.40) 45%,
    rgba(4,5,11,.12) 62%, transparent 76%);
}

.ch-inner{
  position: relative;
  width: min(38rem, 46vw);
  margin: 0 clamp(2.5rem, 7vw, 8rem);
  padding: 2.4rem 0 2.6rem;
}

.ch-head{
  display: flex;
  align-items: center;
  gap: .9rem;
  margin-bottom: 1.05rem;
}
.ch-num{
  font-family: var(--roman);
  font-size: .82rem;
  letter-spacing: .34em;
  color: var(--gold);
  text-shadow: 0 0 22px rgba(216,177,105,.45);
}
.ch-rule{
  flex: 0 0 auto;
  width: clamp(2rem, 5vw, 4.5rem);
  height: 1px;
  background: linear-gradient(90deg, var(--edge), transparent);
}
.ch-greek{
  font-family: var(--roman);
  font-size: .74rem;
  letter-spacing: .2em;
  color: rgba(203,191,166,.72);
}

.ch-title{
  font-family: var(--roman);
  font-weight: 500;
  font-size: clamp(2.1rem, 4.1vw, 3.5rem);
  line-height: 1.06;
  letter-spacing: .012em;
  margin: 0 0 1.25rem;
  color: #fff;
  text-shadow:
    0 1px 0 rgba(0,0,0,.55),
    0 0 44px rgba(240,217,166,.28),
    0 0 100px rgba(0,0,0,.85);
}
/* small gilt underline */
.ch-title::after{
  content: '';
  display: block;
  width: 3.4rem;
  height: 2px;
  margin-top: 1.1rem;
  background: linear-gradient(90deg, var(--gold), rgba(216,177,105,0));
  box-shadow: 0 0 18px rgba(216,177,105,.5);
}

.chapter p{
  font-size: clamp(1.06rem, 1.32vw, 1.3rem);
  font-weight: 300;
  line-height: 1.72;
  letter-spacing: .006em;
  color: rgba(243,233,213,.93);
  margin: 0 0 1.05rem;
  text-shadow: 0 1px 2px rgba(0,0,0,.8), 0 0 30px rgba(0,0,0,.75);
  text-wrap: pretty;
}
.chapter p:first-of-type::first-letter{
  font-family: var(--roman);
  float: left;
  font-size: 3.15em;
  line-height: .84;
  padding: .06em .12em 0 0;
  color: var(--gold-2);
  text-shadow: 0 0 30px rgba(216,177,105,.5);
}
.chapter p:last-child{ margin-bottom: 0; }

/* ---- chapter rail -------------------------------------------------------- */
#rail{
  position: fixed;
  z-index: 5;
  right: clamp(.9rem, 1.8vw, 1.8rem);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: .58rem;
  opacity: 0;
  transition: opacity 1.1s ease 0.3s;
}
body.begun #rail{ opacity: 1; }

.rail-dot{
  appearance: none;
  background: none;
  border: 0;
  padding: .17rem .1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .6rem;
}
.rail-dot i{
  display: block;
  width: 15px; height: 1px;
  background: rgba(243,233,213,.30);
  transition: width .45s cubic-bezier(.2,.8,.2,1), background .45s ease, box-shadow .45s ease;
}
.rail-dot span{
  font-family: var(--roman);
  font-size: .62rem;
  letter-spacing: .13em;
  color: rgba(243,233,213,.0);
  white-space: nowrap;
  transition: color .35s ease;
  text-shadow: 0 1px 10px rgba(0,0,0,.9);
  order: -1;
}
.rail-dot:hover i{ width: 26px; background: var(--gold-2); }
.rail-dot:hover span{ color: rgba(243,233,213,.9); }
.rail-dot.is-active i{
  width: 30px;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(216,177,105,.85);
}
.rail-dot.is-active span{ color: rgba(216,177,105,.95); }

/* ---- sound toggle -------------------------------------------------------- */
.sound{
  position: fixed;
  z-index: 6;
  top: clamp(1rem, 2.2vw, 1.9rem);
  right: clamp(1rem, 2.2vw, 1.9rem);
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .5rem .85rem .5rem .7rem;
  border: 1px solid rgba(216,177,105,.28);
  border-radius: 2rem;
  background: rgba(6,7,13,.42);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  color: rgba(243,233,213,.82);
  font-family: var(--roman);
  font-size: .62rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transition: opacity 1s ease .3s, border-color .3s ease, color .3s ease, background .3s ease;
}
body.begun .sound{ opacity: 1; }
.sound:hover{ border-color: var(--gold); color: #fff; background: rgba(6,7,13,.62); }
.sound svg{ width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5;
            stroke-linecap: round; stroke-linejoin: round; }
.sound .spk{ fill: currentColor; stroke-width: 1; }
.sound .w1, .sound .w2{ opacity: 0; transition: opacity .3s ease; }
.sound .x{ opacity: .85; transition: opacity .3s ease; }
.sound.is-on{ color: var(--gold-2); border-color: rgba(216,177,105,.6); }
.sound.is-on .w1, .sound.is-on .w2{ opacity: 1; }
.sound.is-on .x{ opacity: 0; }

/* ---- scroll hint --------------------------------------------------------- */
.hint{
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: clamp(1.2rem, 3vh, 2.4rem);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  font-family: var(--roman);
  font-size: .6rem;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: rgba(243,233,213,.5);
  opacity: 0;
  transition: opacity 1.1s ease;
  pointer-events: none;
}
body.begun .hint{ opacity: 1; animation: bob 3.4s ease-in-out infinite; }
.hint.gone{ opacity: 0 !important; animation: none; }
.hint svg{ width: 11px; height: 27px; fill: none; stroke: currentColor;
           stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes bob{ 0%,100%{ transform: translate(-50%, 0); } 50%{ transform: translate(-50%, 7px); } }

/* ---- intro --------------------------------------------------------------- */
.intro{
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
  background:
    radial-gradient(85% 70% at 50% 45%, rgba(6,7,13,.62), rgba(4,5,10,.92) 70%),
    rgba(4,5,10,.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: opacity 1.4s ease, backdrop-filter 1.4s ease;
}
.intro.gone{ opacity: 0; pointer-events: none; backdrop-filter: blur(0); }

.intro-inner{ max-width: 40rem; animation: rise 1.8s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise{ from{ opacity: 0; transform: translateY(20px); } to{ opacity: 1; transform: none; } }

.intro-mark svg{
  width: clamp(62px, 9vw, 92px);
  height: auto;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1;
  opacity: .68;
  margin-bottom: 1.4rem;
  animation: spin 90s linear infinite;
}
.intro-mark circle:last-of-type{ fill: rgba(216,177,105,.16); }
@keyframes spin{ to{ transform: rotate(360deg); } }

.intro h1{
  font-family: var(--roman);
  font-weight: 500;
  font-size: clamp(2.3rem, 6.4vw, 4.6rem);
  letter-spacing: clamp(.1em, .05em + .5vw, .22em);
  margin: 0 0 .35rem;
  color: #fff;
  text-shadow: 0 0 60px rgba(216,177,105,.42), 0 2px 4px rgba(0,0,0,.7);
}
.intro-sub{
  font-family: var(--roman);
  font-size: clamp(.68rem, 1.1vw, .8rem);
  letter-spacing: .48em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 2rem;
  padding-left: .48em;
}
.intro-line{
  font-size: clamp(1.02rem, 1.5vw, 1.24rem);
  font-weight: 300;
  font-style: italic;
  line-height: 1.75;
  color: rgba(243,233,213,.86);
  margin: 0 auto 2.4rem;
  max-width: 32rem;
  text-wrap: pretty;
}

.intro-actions{ display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.btn{
  appearance: none;
  cursor: pointer;
  font-family: var(--roman);
  font-size: .66rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  padding: .95rem 1.7rem;
  border-radius: 2rem;
  border: 1px solid rgba(216,177,105,.34);
  background: transparent;
  color: rgba(243,233,213,.78);
  transition: all .35s cubic-bezier(.2,.8,.2,1);
}
.btn:hover{ border-color: var(--gold); color: #fff; transform: translateY(-2px); }
.btn-primary{
  background: linear-gradient(180deg, rgba(216,177,105,.20), rgba(216,177,105,.06));
  border-color: rgba(216,177,105,.7);
  color: var(--gold-2);
  box-shadow: 0 0 34px rgba(216,177,105,.16), inset 0 0 22px rgba(216,177,105,.07);
}
.btn-primary:hover{ box-shadow: 0 0 52px rgba(216,177,105,.30), inset 0 0 26px rgba(216,177,105,.12); }

.intro-note{
  margin: 2.1rem 0 0;
  font-size: .78rem;
  font-style: italic;
  color: rgba(203,191,166,.42);
}

/* ---- fallback ------------------------------------------------------------ */
.fallback{
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 2rem; text-align: center;
  background: #06070d; color: var(--muted); font-size: 1.05rem;
}
.fallback[hidden]{ display: none; }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 1024px){
  .ch-inner{ width: min(34rem, 62vw); margin: 0 clamp(2rem, 6vw, 4rem); }
}

@media (max-width: 760px){
  .chapter, .chapter.is-left, .chapter.is-right{
    justify-content: center;
    align-items: flex-end;
  }
  .ch-inner{
    width: 100%;
    margin: 0;
    padding: 1.6rem 1.5rem 5.2rem;
  }
  /* on narrow screens the scrim comes up from the bottom instead; stops are
     in vh because the box extends 60vh past the viewport at both ends */
  .chapter.is-left::before,
  .chapter.is-right::before{
    background: linear-gradient(0deg,
      rgba(4,5,11,.94) 90vh, rgba(4,5,11,.78) 112vh, rgba(4,5,11,.30) 134vh, transparent 152vh);
  }
  .ch-title{ font-size: clamp(1.7rem, 7.6vw, 2.3rem); margin-bottom: .9rem; }
  .ch-title::after{ margin-top: .8rem; }
  .chapter p{ font-size: 1.02rem; line-height: 1.62; margin-bottom: .8rem; }
  .chapter p:first-of-type::first-letter{ font-size: 2.6em; }
  #rail{ right: .55rem; gap: .42rem; }
  .rail-dot span{ display: none; }
  .rail-dot i{ width: 10px; }
  .rail-dot.is-active i{ width: 20px; }
  .sound .sound-label{ display: none; }
  .sound{ padding: .55rem .6rem; }
  .hint{ bottom: 1rem; }
}

@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior: auto; }
  .intro-mark svg{ animation: none; }
  body.begun .hint{ animation: none; }
  .chapter{ transition: none; }
}
