/* ==========================================================
   Shantha Bible — home hero (mobile first)
   Black & white system shared with Shantha Hi Tech / Books /
   Faculty Assist: pure black, white Inter, tracked uppercase
   labels, pill buttons, white particle visuals.
   ========================================================== */

/* ---------- Theme tokens ----------
   --ink is the foreground as an RGB triplet so any alpha can be derived.
   Dark is the brand default; light is its exact inverse with softer
   shadows and overlays. */
:root,
:root[data-theme="dark"] {
  --ink: 255, 255, 255;
  --bg: #000;
  --fg: #fff;
  --card: #050505;
  --sheet: #0a0a0a;
  --sheet-rgb: 10, 10, 10;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: rgba(0, 0, 0, 0.65);
  --particle: #fff;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --ink: 0, 0, 0;
  --bg: #fff;
  --fg: #000;
  --card: #fafafa;
  --sheet: #fff;
  --sheet-rgb: 255, 255, 255;
  --scrim: rgba(0, 0, 0, 0.28);
  --shadow: rgba(0, 0, 0, 0.14);
  --particle: #000;
  color-scheme: light;
}

:root {
  --muted: rgba(var(--ink), 0.64);
  --faint: rgba(var(--ink), 0.22);
  --pad: 20px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  /* Inter for Latin; Tamil characters fall through to Noto Sans Tamil */
  --sans: "Inter", "Noto Sans Tamil", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

* { margin: 0; padding: 0; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
ol { list-style: none; }

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

/* ---------- Hero shell ---------- */

.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
}

.hero__canvas {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Header ---------- */

.header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) var(--pad) 0;
}

/* Symbol, then the name. Everything is sized from the font size on .logo */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.26em;
  font-size: 31px;
  line-height: 1;
  text-decoration: none;
}

.logo__sym {
  flex: none;
  width: 1.18em;
  height: 1.5em;
  background: currentColor; /* the symbol takes the text colour in day and night */
  -webkit-mask: url(icons/logo-mark.png) center / contain no-repeat;
  mask: url(icons/logo-mark.png) center / contain no-repeat;
}

.logo__text {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.logo__mark {
  font-size: 1em;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.logo__sub {
  margin-bottom: 1px;
  font-family: "Kaushan Script", "Brush Script MT", cursive;
  font-size: 14px;
  letter-spacing: 0.01em;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 15px;
  border: 1px solid rgba(var(--ink), 0.5);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  transition: background-color 0.3s, color 0.3s;
}

.burger {
  display: grid;
  place-content: center;
  gap: 6px;
  width: 44px;
  height: 44px;
  margin-right: -8px;
}

.burger span {
  display: block;
  width: 26px;
  height: 1.5px;
  background: var(--fg);
}

/* ---------- Stage (where the particle Bible floats) ---------- */

.stage {
  flex: 1 1 auto;
  min-height: 250px;
}

/* ---------- Copy ---------- */

.content {
  padding: 0 var(--pad) calc(26px + env(safe-area-inset-bottom));
}

.eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.hero .actions { justify-content: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  padding: 0 24px;
  border: 1px solid var(--fg);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background-color 0.3s, color 0.3s, transform 0.3s var(--ease-out);
}

.btn:active { transform: scale(0.97); }
.btn--ghost { border-color: rgba(var(--ink), 0.6); }
.btn--solid { background: var(--fg); color: var(--bg); }

@media (hover: hover) {
  .pill:hover,
  .btn--ghost:hover { background: var(--fg); color: var(--bg); }
  .btn--solid:hover { background: transparent; color: var(--fg); }
}

/* ---------- Load-in choreography ---------- */

.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 1s var(--ease-out),
    transform 1s var(--ease-out);
  transition-delay: calc(0.25s + var(--d, 0) * 0.12s);
}

.is-ready .reveal { opacity: 1; transform: none; }

/* No JS: show everything, first verse only */
.no-js .reveal { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { transition: none !important; transition-delay: 0s !important; }
}

/* Very short phones (iPhone SE with browser chrome): tighten rhythm */
@media (max-height: 700px) {
  .actions { margin-top: 18px; }
  .stage { min-height: 220px; }
}

/* ==========================================================
   Language switch (English · தமிழ் · English + தமிழ்)
   ========================================================== */

.langmenu { position: relative; }

.langmenu__btn { gap: 8px; }

.langmenu__chev {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s var(--ease-out);
}

.langmenu__btn[aria-expanded="true"] .langmenu__chev { transform: rotate(180deg); }
.langmenu__current { transition: opacity 0.2s ease; }

.langmenu__list {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  width: min(276px, calc(100vw - 32px));
  padding: 8px;
  border: 1px solid rgba(var(--ink), 0.16);
  border-radius: 22px;
  background: rgba(var(--sheet-rgb), 0.94);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px var(--shadow);
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  transform-origin: top right;
  transition: opacity 0.22s ease, transform 0.3s var(--ease-out);
}

.langmenu__list.is-open { opacity: 1; transform: none; }

.langmenu__title {
  padding: 8px 10px 10px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border-radius: 14px;
  text-align: left;
  transition: background-color 0.2s;
}

.opt + .opt { margin-top: 2px; }
.opt:focus-visible { outline: 1px solid rgba(var(--ink), 0.6); outline-offset: -1px; }
.opt[aria-checked="true"] { background: rgba(var(--ink), 0.07); }

.opt__glyph {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(var(--ink), 0.2);
  border-radius: 12px;
  font-size: 16px;
  transition: background-color 0.25s, color 0.25s, border-color 0.25s;
}

.opt__glyph--both {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1px;
  font-size: 12.5px;
}

.opt[aria-checked="true"] .opt__glyph { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.opt__text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.opt__t { font-size: 15px; }
.opt__s { font-size: 12px; color: var(--muted); }

.opt__check {
  display: grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--fg);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.25s, transform 0.35s var(--ease-out);
}

.opt__check svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: var(--bg);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.opt[aria-checked="true"] .opt__check { opacity: 1; transform: none; }

@media (hover: hover) {
  .opt:hover { background: rgba(var(--ink), 0.05); }
}

/* Crossfade while the language changes */
.content,
.finder,
.sheet__viewport,
.sheet__head { transition: opacity 0.2s ease; }

.is-lang-fading .content,
.is-lang-fading .finder,
.is-lang-fading .sheet__viewport,
.is-lang-fading .sheet__head,
.is-lang-fading .langmenu__current { opacity: 0; }

/* ---------- Tamil typography ----------
   Tamil has no capitals and wide tracking breaks up its letter clusters,
   so tracked uppercase labels go back to normal spacing and grow a little. */
.eyebrow:lang(ta),
.btn:lang(ta),
.pill:lang(ta),
.field__label:lang(ta),
.tab__k:lang(ta),
.popular__label:lang(ta),
.view__meta:lang(ta),
.seg-toggle button:lang(ta),
.langmenu__title :lang(ta),
.eyebrow :lang(ta),
.pill :lang(ta),
.view__meta :lang(ta),
.seg-toggle :lang(ta) {
  letter-spacing: 0.01em;
  text-transform: none;
}

.eyebrow:lang(ta) { font-size: 13px; }
.btn:lang(ta) { font-size: 13.5px; font-weight: 500; }
.field__label:lang(ta),
.tab__k:lang(ta) { font-size: 11px; }
.popular__label:lang(ta),
.view__meta:lang(ta) { font-size: 12.5px; }
.seg-toggle button:lang(ta) { font-size: 13px; }

/* ==========================================================
   Theme toggle (sun / moon)
   ========================================================== */

.theme-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  transition: background-color 0.3s, color 0.3s;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  overflow: visible;
}

/* Half-lit disc: turns a half circle when the theme changes */
.tt-ring { fill: none; stroke: currentColor; stroke-width: 1.25; }

.tt-half {
  fill: currentColor;
  transform-origin: 12px 12px;
  transition: transform 0.6s var(--ease-out);
}

[data-theme="light"] .tt-half { transform: rotate(180deg); }

@media (hover: hover) {
  .theme-toggle { position: relative; }

  .theme-toggle::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    z-index: 30;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--fg);
    color: var(--bg);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -3px);
    transition: opacity 0.15s, transform 0.15s;
  }

  .theme-toggle:hover::after,
  .theme-toggle:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
}

/* Circular reveal when the theme changes (View Transitions API) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* Fallback for browsers without view transitions */
.is-theme-fading body,
.is-theme-fading .finder__card,
.is-theme-fading .btn,
.is-theme-fading .pill {
  transition: background-color 0.45s ease, color 0.45s ease, border-color 0.45s ease;
}

@media (prefers-reduced-motion: reduce) {
  .tt-half { transition: none; }
}

/* Tighter header on very narrow phones */
@media (max-width: 359px) {
  .header__actions { gap: 6px; }
  .pill { padding: 0 11px; }
  .logo { font-size: 27px; }
}

/* ---------- One frame for every page ----------
   The logo, top bar buttons and footer all sit on this side margin,
   and the logo keeps one size, so nothing jumps between pages. */
:root { --edge: var(--pad); }

@media (max-width: 359px) {
  :root { --pad: 16px; }
}

@media (min-width: 600px) {
  :root { --edge: max(clamp(32px, 5.5vw, 96px), calc((100vw - 1560px) / 2)); }
  .logo { font-size: 36px; }
  .logo__sub { font-size: 15px; }
}

@media (min-width: 1100px) and (min-height: 560px) and (min-aspect-ratio: 1/1), (min-width: 1280px) {
  .logo { font-size: 38px; }
  .logo__sub { font-size: 16px; }
}

/* Phones: the logo shares the top bar with the language and menu buttons */
@media (max-width: 480px) {
  .header .logo,
  .cbar .logo { flex: none; font-size: 25px; }
  .header .logo__sub,
  .cbar .logo__sub { font-size: 11.5px; }
  .header .langmenu__chev { display: none; }
}

@media (max-width: 359px) {
  .header .logo,
  .cbar .logo,
  .rbar .logo { font-size: 20px; }
  .header .logo__sub,
  .cbar .logo__sub,
  .rbar .logo__sub { font-size: 10px; }
}

/* Phones turned sideways keep a slim frame */
@media (max-height: 540px) and (min-width: 560px) and (min-aspect-ratio: 3/2) {
  :root { --edge: max(20px, env(safe-area-inset-left)); }
  .logo { font-size: 26px; }
  .logo__sub { font-size: 11px; }
}

@media (horizontal-viewport-segments: 2) {
  :root { --edge: 28px; }
}
