:root {
  --ink: #241713;
  --paper: #f8efe2;
  --maroon: #6d211f;
  --copper: #a66036;
  --teal: #315f62;
  --gold: #c69a4b;
  --line: rgba(80, 45, 32, .18);
  --hero-height: clamp(230px, 32dvh, 330px);
  --stanza-image-width: min(48vw, calc((100dvh - var(--hero-height)) * .8));
}
* { box-sizing: border-box; }
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Georgia, "Noto Serif Tamil", "Tamil MN", serif;
  user-select: none;
  -webkit-user-select: none;
}
img {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}
.alt-page {
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: var(--hero-height) minmax(0, 1fr);
}
.alt-hero {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr) minmax(320px, 460px);
  align-items: start;
  gap: 30px;
  height: var(--hero-height);
  padding: 14px 10px;
  color: #fffaf2;
  overflow: visible;
  background-color: #2a1713;
  background-image:
    linear-gradient(90deg, rgba(36, 23, 19, .94), rgba(36, 23, 19, .62) 48%, rgba(36, 23, 19, .42)),
    var(--cover-image);
  background-position: center;
  background-size: cover;
  border-bottom: 1px solid rgba(255, 250, 242, .18);
}
.hero-meta {
  min-width: 0;
  display: grid;
  grid-template-rows: 26px repeat(4, 42px);
  align-content: end;
  gap: 7px;
  height: 100%;
  padding-bottom: 14px;
}
.index-link {
  width: 220px;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 4px 9px;
  color: #e2c684;
  font: 800 12px/1.2 system-ui, sans-serif;
  text-decoration: none;
}
.hero-copy {
  min-width: 0;
  max-width: min(760px, 100%);
  display: grid;
  grid-template-rows: max-content max-content minmax(0, 1fr);
  align-content: start;
  overflow: hidden;
}
.hero-copy h1 {
  margin: 28px 0 0;
  font-size: clamp(30px, 3.2vw, 50px);
  line-height: .98;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
}
.hero-copy strong {
  display: block;
  margin-top: 8px;
  color: #9dd1d2;
  font: 800 13px/1.3 system-ui, sans-serif;
}
.summary-spacer {
  visibility: hidden;
}
.hero-copy span {
  display: -webkit-box;
  max-width: 760px;
  max-height: 3.1em;
  margin-top: 8px;
  overflow: hidden;
  color: rgba(255, 250, 242, .9);
  font-size: 18px;
  line-height: 1.55;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.meta-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 220px;
  display: grid;
  gap: 7px;
  font: 700 12px/1.2 system-ui, sans-serif;
  color: rgba(255, 250, 242, .92);
}
.meta-list li {
  min-height: 42px;
  padding: 10px 9px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 250, 242, .2);
  border-radius: 999px;
  background: rgba(255, 250, 242, .12);
  backdrop-filter: blur(10px);
}
.chapter-dial {
  position: relative;
  justify-self: end;
  width: min(460px, 100%);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 6px;
}
.dial-face {
  text-align: right;
  border: 1px solid rgba(255, 250, 242, .08);
  border-radius: 18px;
  background: transparent;
  color: #fffaf2;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: none;
  backdrop-filter: blur(4px);
  text-decoration: none;
}
.dial-face span {
  display: block;
  color: #e2c684;
  font: 800 12px/1.3 system-ui, sans-serif;
}
.dial-face strong {
  display: block;
  font-size: clamp(14px, 1.15vw, 20px);
  line-height: 1.1;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
}
.dial-step {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #fffaf2;
  text-decoration: none;
  border: 1px solid rgba(255, 250, 242, .12);
  border-radius: 999px;
  background: transparent;
  font: 400 28px/1 Georgia, serif;
  backdrop-filter: blur(4px);
  transition: transform .18s ease, border-color .18s ease;
}
.dial-step:hover,
.dial-step:focus-visible,
.dial-face:hover,
.dial-face:focus-visible {
  border-color: rgba(255, 250, 242, .32);
  outline: none;
  transform: translateY(-1px);
}
.stanza-shell {
  position: relative;
  min-height: 0;
  overflow: hidden;
}
.stanza-stage,
.stanza-viewport {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.stanza-card {
  display: none;
  grid-template-columns: var(--stanza-image-width) minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  gap: 0;
  align-items: stretch;
}
.stanza-card.is-active {
  display: grid;
}
.stanza-card figure {
  margin: 0;
  width: var(--stanza-image-width);
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
}
.stanza-card img,
.image-placeholder {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left top;
  display: block;
}
.image-placeholder {
  display: grid;
  place-items: center;
  color: rgba(36, 23, 19, .72);
  font: 800 18px/1.3 system-ui, sans-serif;
}
.stanza-copy {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  align-content: start;
  padding: clamp(70px, 10dvh, 118px) clamp(24px, 4vw, 60px) 24px;
}
.stanza-copy::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--chapter-bg-image);
  background-position: center;
  background-size: cover;
  opacity: .42;
  filter: saturate(.85);
}
.stanza-number {
  color: var(--teal);
  font: 800 13px/1.3 system-ui, sans-serif;
}
.tamil {
  margin: 12px 0 2.8em;
  white-space: pre-line;
  font-size: clamp(18px, 1.55vw, 24px);
  line-height: 1.42;
}
.meaning {
  margin: 0;
  max-width: 64ch;
  color: #765f55;
  font: 14px/1.45 system-ui, sans-serif;
}
.nav-arrow {
  position: absolute;
  z-index: 5;
  top: 50%;
  width: 48px;
  height: 48px;
  transform: translateY(-50%);
  border: 1px solid rgba(80, 45, 32, .12);
  border-radius: 999px;
  background: transparent;
  color: var(--maroon);
  font: 400 32px/1 Georgia, serif;
  cursor: pointer;
  box-shadow: none;
  backdrop-filter: blur(4px);
}
.nav-arrow:hover,
.nav-arrow:focus-visible {
  background: rgba(255, 250, 242, .22);
  outline: none;
}
.nav-arrow.left { left: 18px; }
.nav-arrow.right { right: 18px; }
.stanza-counter {
  position: absolute;
  z-index: 4;
  inset-inline: 0;
  bottom: 14px;
  width: max-content;
  margin: auto;
  padding: 7px 12px;
  border: 1px solid rgba(80, 45, 32, .14);
  border-radius: 999px;
  background: rgba(255, 250, 242, .72);
  color: #765f55;
  font: 800 12px/1.2 system-ui, sans-serif;
  backdrop-filter: blur(10px);
}
@media (max-width: 900px) {
  :root { --hero-height: clamp(220px, 34dvh, 310px); }
  .alt-hero {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px;
  }
  .hero-meta {
    order: 2;
    height: auto;
    padding: 0;
  }
  .hero-copy { order: 1; }
  .meta-list {
    display: flex;
    flex-wrap: wrap;
  }
  .hero-copy { max-width: 100%; }
  .hero-copy h1 { font-size: clamp(34px, 10vw, 58px); }
  .hero-copy span { font-size: 16px; -webkit-line-clamp: 2; }
  .meta-list { gap: 6px; }
  .meta-list li { padding: 7px 10px; font-size: 12px; }
  .chapter-dial {
    position: absolute;
    top: 16px;
    right: 16px;
    width: min(58vw, 280px);
  }
  .dial-face strong { font-size: 20px; }
  .stanza-card {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 52%) minmax(0, 48%);
  }
  .stanza-copy {
    align-content: center;
    padding: 18px 22px 44px;
  }
  .tamil {
    font-size: clamp(18px, 5.2vw, 26px);
    line-height: 1.45;
  }
  .meaning { font-size: 13px; line-height: 1.45; }
  .nav-arrow {
    width: 42px;
    height: 42px;
    font-size: 28px;
  }
}

.index-body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  background: #241713;
}
.chapter-index {
  min-height: 100vh;
  color: #fffaf2;
  background:
    linear-gradient(180deg, rgba(36, 23, 19, .82), rgba(36, 23, 19, .96)),
    url("../ch01/ch01-sivapuranam-img000.png");
  background-attachment: fixed;
  background-position: center;
  background-size: cover;
  padding: 4px;
}
.index-hero {
  max-width: none;
  margin: 0 0 8px;
}
.index-hero span {
  color: #e2c684;
  font: 800 13px/1.2 system-ui, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.index-hero h1 {
  margin: 10px 0 0;
  font-size: clamp(48px, 8vw, 116px);
  line-height: .95;
}
.chapter-grid {
  max-width: none;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
}
.chapter-link {
  min-height: 230px;
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: end;
  gap: 5px;
  padding: 12px;
  color: #fffaf2;
  text-decoration: none;
  border: 1px solid rgba(255, 250, 242, .14);
  border-radius: 8px;
  background-color: #2a1713;
  background-position: center;
  background-size: cover;
}
.chapter-link:hover,
.chapter-link:focus-visible {
  border-color: rgba(226, 198, 132, .65);
  outline: none;
}
.chapter-link span {
  color: #e2c684;
  font: 800 12px/1.25 system-ui, sans-serif;
}
.chapter-link strong {
  font-size: 28px;
  line-height: 1.05;
}
.chapter-link em {
  color: rgba(255, 250, 242, .8);
  font: 700 12px/1.25 system-ui, sans-serif;
  font-style: normal;
}

@media (max-width: 900px) {
  :root { --hero-height: clamp(156px, 24dvh, 196px); }
  .alt-hero { display: block; padding: 10px 12px; }
  .hero-meta { display: block; padding: 0; }
  .index-link { width: auto; padding: 0; font-size: 11px; }
  .meta-list { display: none; }
  .hero-copy { display: block; padding-top: 5px; }
  .hero-copy h1 { margin-top: 8px; padding-right: 0; font-size: clamp(27px, 8vw, 36px); }
  .hero-copy span { max-width: calc(100% - 172px); margin-top: 6px; font-size: 13px; line-height: 1.35; -webkit-line-clamp: 2; }
  .chapter-dial { top: 12px; right: 12px; width: min(46vw, 174px); grid-template-columns: 26px minmax(0, 1fr) 26px; gap: 3px; }
  .dial-face { padding: 7px 6px; border-radius: 12px; }
  .dial-face span { font-size: 9px; }
  .dial-face strong { font-size: 13px; }
  .dial-step { width: 26px; height: 26px; font-size: 21px; }
  .stanza-stage { touch-action: pan-y; }
  .stanza-card { grid-template-rows: minmax(0, 46%) minmax(0, 54%); }
  .stanza-copy { align-content: start; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 16px 50px 42px; }
  .tamil { margin: 10px 0 26px; font-size: clamp(17px, 5vw, 23px); line-height: 1.4; }
  .meaning { font-size: 13px; line-height: 1.45; }
  .nav-arrow { width: 38px; height: 38px; font-size: 25px; border-color: transparent; background: rgba(248, 239, 226, .32); }
  .nav-arrow.left { left: 5px; }
  .nav-arrow.right { right: 5px; }
}
