@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=Noto+Serif:wght@400;500;600&family=Noto+Serif+Bengali:wght@400;600&family=Noto+Serif+Devanagari:wght@400;600;700&family=Noto+Serif+Gujarati:wght@400;600&family=Noto+Serif+Kannada:wght@400;600&family=Noto+Serif+Malayalam:wght@400;600&family=Noto+Serif+Oriya:wght@400;600&family=Noto+Serif+Tamil:wght@400;600&family=Noto+Serif+Telugu:wght@400;600&display=swap");

:root {
  color-scheme: light dark;
  --ink: #19130f;
  --ink-soft: #4d392c;
  --paper: #f7efdf;
  --paper-soft: #eadfc8;
  --copper: #b76d32;
  --saffron: #d3a13d;
  --peacock: #1e6b5b;
  --lotus: #a44768;
  --charcoal: #101715;
  --focus: #f0bf52;
  --border-dark: rgba(247, 239, 223, 0.24);
  --border-light: rgba(25, 19, 15, 0.18);
  font-family: "Noto Serif", Georgia, serif;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--charcoal);
  color: var(--paper);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: -2;
  background: url("/manuscript-texture.png") center / cover no-repeat;
  filter: saturate(0.92) contrast(1.05);
}

body::after {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(12, 18, 16, 0.92), rgba(39, 29, 19, 0.58) 46%, rgba(12, 18, 16, 0.72)),
    radial-gradient(circle at 72% 18%, rgba(180, 95, 48, 0.22), transparent 28%),
    radial-gradient(circle at 24% 82%, rgba(30, 107, 91, 0.28), transparent 34%);
}

a {
  color: inherit;
}

button,
select {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1rem 1.5rem;
  color: var(--paper);
  background: linear-gradient(180deg, rgba(15, 18, 16, 0.86), rgba(15, 18, 16, 0.52));
  border-bottom: 1px solid var(--border-dark);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 0.8rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  color: var(--saffron);
  border: 1px solid rgba(211, 161, 61, 0.42);
  border-radius: 50%;
  font-family: "Noto Serif Devanagari", serif;
  font-size: 1.15rem;
  line-height: 1;
}

.brand-title,
.brand-subtitle,
.script-picker span,
.meta,
.script-label,
.meaning-label,
.verse-count {
  letter-spacing: 0;
}

.brand-title {
  display: block;
  font-family: "Cormorant Garamond", "Noto Serif", serif;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
}

.brand-subtitle {
  display: block;
  margin-top: 0.2rem;
  color: rgba(247, 239, 223, 0.7);
  font-size: 0.72rem;
  line-height: 1;
  text-transform: uppercase;
}

.script-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: rgba(247, 239, 223, 0.78);
  font-size: 0.82rem;
}

.script-picker select {
  min-width: 10.5rem;
  border: 1px solid rgba(247, 239, 223, 0.28);
  border-radius: 999px;
  padding: 0.58rem 2.3rem 0.58rem 0.95rem;
  background: rgba(12, 17, 15, 0.72);
  color: var(--paper);
  cursor: pointer;
}

.verse-nav {
  position: fixed;
  z-index: 18;
  right: 1.2rem;
  top: 50%;
  display: grid;
  gap: 0.75rem;
  transform: translateY(-50%);
}

.verse-nav a {
  width: 0.72rem;
  height: 0.72rem;
  border: 1px solid rgba(247, 239, 223, 0.62);
  border-radius: 50%;
  background: rgba(247, 239, 223, 0.1);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.verse-nav a:hover,
.verse-nav a:focus-visible {
  background: var(--saffron);
  border-color: var(--saffron);
  transform: scale(1.18);
}

.panel {
  position: relative;
  display: grid;
  min-height: 100svh;
  padding: 6.25rem 5.5rem 4.4rem;
  scroll-snap-align: start;
  isolation: isolate;
}

.panel::before {
  content: attr(data-ref);
  position: absolute;
  top: 6.65rem;
  right: 2.55rem;
  color: currentColor;
  font-size: 0.78rem;
  line-height: 1;
  opacity: 0.52;
  writing-mode: vertical-rl;
}

.panel::after {
  content: "";
  position: absolute;
  top: 6.4rem;
  bottom: 3.6rem;
  left: 3rem;
  width: 1px;
  background: currentColor;
  opacity: 0.22;
}

.verse-panel {
  align-items: center;
  color: var(--paper);
  background:
    linear-gradient(100deg, rgba(12, 18, 16, 0.94), rgba(17, 24, 21, 0.78) 48%, rgba(104, 58, 34, 0.34)),
    linear-gradient(180deg, rgba(30, 107, 91, 0.12), rgba(164, 71, 104, 0.1));
}

.meaning-panel {
  align-items: center;
  color: var(--ink);
  background:
    linear-gradient(100deg, rgba(247, 239, 223, 0.94), rgba(238, 229, 207, 0.86) 54%, rgba(210, 161, 61, 0.28)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(30, 107, 91, 0.1));
}

.verse-layout,
.meaning-layout {
  width: min(100%, 76rem);
  margin: 0 auto;
}

.verse-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 21rem);
  gap: 2.8rem;
  align-items: center;
}

.meaning-layout {
  display: grid;
  gap: 2rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.7rem;
  margin-bottom: 1.4rem;
  color: rgba(247, 239, 223, 0.76);
  font-size: 0.9rem;
}

.meaning-panel .meta {
  color: rgba(25, 19, 15, 0.68);
}

.meta span:not(:last-child)::after {
  content: "/";
  margin-left: 0.7rem;
  color: var(--saffron);
}

.sanskrit {
  margin: 0;
  font-family: "Noto Serif Devanagari", serif;
  font-size: 3.65rem;
  font-weight: 600;
  line-height: 1.24;
}

.iast {
  margin: 1.45rem 0 0;
  color: rgba(247, 239, 223, 0.8);
  font-family: "Cormorant Garamond", "Noto Serif", serif;
  font-size: 1.55rem;
  font-weight: 500;
  line-height: 1.28;
}

.script-block {
  min-height: 13rem;
  padding-left: 1.2rem;
  border-left: 1px solid rgba(211, 161, 61, 0.46);
}

.script-label,
.meaning-label,
.verse-count {
  color: var(--saffron);
  font-size: 0.82rem;
  line-height: 1;
  text-transform: uppercase;
}

.script-text {
  margin: 0.9rem 0 0;
  font-size: 1.68rem;
  font-weight: 500;
  line-height: 1.42;
}

.script-block[hidden] {
  display: none;
}

.meaning-label {
  color: var(--lotus);
}

.meaning-text {
  max-width: 52rem;
  margin: 0;
  font-family: "Cormorant Garamond", "Noto Serif", serif;
  font-size: 3.65rem;
  font-weight: 500;
  line-height: 1.12;
}

.meaning-note {
  max-width: 38rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1.7;
}

.verse-count {
  position: absolute;
  left: 3rem;
  bottom: 2.8rem;
  color: currentColor;
  opacity: 0.54;
}

[data-script="tamil"] .script-text {
  font-family: "Noto Serif Tamil", "Noto Serif", serif;
}

[data-script="kannada"] .script-text {
  font-family: "Noto Serif Kannada", "Noto Serif", serif;
}

[data-script="telugu"] .script-text {
  font-family: "Noto Serif Telugu", "Noto Serif", serif;
}

[data-script="malayalam"] .script-text {
  font-family: "Noto Serif Malayalam", "Noto Serif", serif;
}

[data-script="bengali"] .script-text {
  font-family: "Noto Serif Bengali", "Noto Serif", serif;
}

[data-script="gujarati"] .script-text {
  font-family: "Noto Serif Gujarati", "Noto Serif", serif;
}

[data-script="odia"] .script-text {
  font-family: "Noto Serif Oriya", "Noto Serif", serif;
}

@media (max-width: 980px) {
  .panel {
    padding: 6.9rem 3rem 4.3rem;
  }

  .panel::before {
    right: 1.4rem;
  }

  .panel::after,
  .verse-count {
    left: 1.6rem;
  }

  .verse-layout {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .sanskrit {
    font-size: 3.1rem;
  }

  .iast {
    font-size: 1.45rem;
  }

  .script-block {
    min-height: 0;
    max-width: 38rem;
  }

  .meaning-text {
    font-size: 3.25rem;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    padding: 0.85rem 1rem;
  }

  .brand-mark,
  .brand-subtitle,
  .verse-nav {
    display: none;
  }

  .brand-title {
    font-size: 1.15rem;
  }

  .script-picker {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.34rem;
    font-size: 0.72rem;
  }

  .script-picker select {
    min-width: 8.5rem;
    max-width: 9rem;
    padding: 0.5rem 0.72rem;
  }

  .panel {
    padding: 5.9rem 1.05rem 3rem;
  }

  .panel::before,
  .panel::after {
    display: none;
  }

  .meta {
    font-size: 0.78rem;
    margin-bottom: 1rem;
  }

  .verse-layout {
    gap: 1.55rem;
  }

  .sanskrit {
    font-size: 2.12rem;
    line-height: 1.32;
  }

  .iast {
    margin-top: 1rem;
    font-size: 1.16rem;
  }

  .script-block {
    padding-left: 1rem;
  }

  .script-text {
    font-size: 1.36rem;
    line-height: 1.42;
  }

  .meaning-text {
    font-size: 2.2rem;
    line-height: 1.18;
  }

  .meaning-note {
    font-size: 1rem;
  }

  .verse-count {
    left: 1.2rem;
    bottom: 2.2rem;
  }
}

@media (max-height: 760px) and (min-width: 981px) {
  .panel {
    padding-top: 5.6rem;
    padding-bottom: 3.4rem;
  }

  .sanskrit {
    font-size: 3.25rem;
    line-height: 1.18;
  }

  .iast {
    margin-top: 1rem;
    font-size: 1.35rem;
  }

  .script-text {
    font-size: 1.48rem;
    line-height: 1.36;
  }

  .script-block {
    min-height: 11rem;
  }

  .meaning-text {
    font-size: 3.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .verse-nav a {
    transition: none;
  }
}
