/* ============================================================
   CONTENT PRESENTATION STYLES
   Five named styles applied to the .content-body wrapper.
   Only one class is active per page; styles are mutually
   exclusive.  Rules are scoped by class so they don't leak
   to default-style content.
   ============================================================ */

/* ---- Shared tokens for all decorative styles ---------------- */
.content-body[class*="style-"] {
  --frame-color:        rgba(201, 150, 43, 0.45);   /* gold-pale outline */
  --frame-color-strong: rgba(201, 150, 43, 0.7);
  --frame-bg:           rgba(251, 240, 211, 0.35);  /* very subtle warm cream */
  --ornament-color:     rgba(201, 150, 43, 0.55);
  position: relative;
  margin: 28px 0 36px;
}

/* ============================================================
   STYLE 1 — MANUSCRIPT PAGE
   Subtle double-line frame with mandala roundels in the four
   corners. Reads like an illuminated manuscript folio.
   ============================================================ */
.content-body.style-manuscript {
  padding: 56px 48px 48px;
  background: var(--frame-bg);
  border: 1px solid var(--frame-color);
  border-radius: 4px;            /* almost square — historical proportion */
  box-shadow:
    inset 0 0 0 1px var(--paper),                          /* gap between borders */
    inset 0 0 0 5px var(--frame-color);                    /* outer line */
}

/* The four mandala roundels in the corners */
.content-body.style-manuscript::before,
.content-body.style-manuscript::after {
  content: "";
  position: absolute;
  width: 48px;
  height: 48px;
  background-image: url('/assets/img/ornaments/mandala-corner.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  /* Tint the SVG via filter — the SVG uses currentColor as stroke */
  opacity: 0.55;
  pointer-events: none;
}
.content-body.style-manuscript::before {
  top: 8px; left: 8px;
}
.content-body.style-manuscript::after {
  bottom: 8px; right: 8px;
  transform: rotate(180deg);     /* mirror the mandala for visual variety */
}
/* Two more corners via an injected element (CSS pseudo-elements
   only give us two; we add a wrapper if we need four corners.
   For now, two corners is plenty — top-left + bottom-right. */

/* Verse blocks inside manuscript style */
.content-body.style-manuscript .verse {
  position: relative;
  padding: 12px 0 12px 48px;
  margin: 18px 0;
}
.content-body.style-manuscript .verse .num {
  position: absolute;
  left: 0;
  top: 12px;
  font-family: var(--display);
  font-size: 1.6rem;
  color: var(--gold);
  font-weight: 600;
  line-height: 1;
}

@media (max-width: 760px) {
  .content-body.style-manuscript {
    padding: 40px 24px 32px;
    box-shadow:
      inset 0 0 0 1px var(--paper),
      inset 0 0 0 4px var(--frame-color);
  }
  .content-body.style-manuscript::before,
  .content-body.style-manuscript::after {
    width: 32px;
    height: 32px;
  }
}

/* ============================================================
   STYLE 2 — LOTUS PETAL FRAME
   Card with scalloped lotus-petal arcs at top and bottom,
   lotus-bud dividers between sections.
   ============================================================ */
.content-body.style-lotus {
  padding: 64px 36px;
  background: var(--paper);
  position: relative;
  /* No hard border — the petal SVG provides the visual frame */
}

/* Top + bottom petal-edge ornaments via SVG mask trick.
   Use a repeating SVG of three lotus-petal arcs as the top and
   bottom edges. */
.content-body.style-lotus::before,
.content-body.style-lotus::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, 90%);
  height: 24px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 24' fill='none' stroke='%23c9962b' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round' opacity='0.6'><path d='M30 22 C 60 4, 90 4, 120 22 M120 22 C 150 4, 180 4, 210 22 M210 22 C 240 4, 270 4, 300 22 M300 22 C 330 4, 360 4, 390 22 M390 22 C 420 4, 450 4, 480 22 M480 22 C 510 4, 540 4, 570 22'/></svg>");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
}
.content-body.style-lotus::before {
  top: 18px;
}
.content-body.style-lotus::after {
  bottom: 18px;
  transform: translateX(-50%) rotate(180deg);
}

/* Section dividers inside a lotus-style content body get the
   bud divider naturally between major sections */
.content-body.style-lotus h2,
.content-body.style-lotus h3 {
  position: relative;
  text-align: center;
  margin-top: 2.4em;
  padding-top: 36px;
}
.content-body.style-lotus h2::before,
.content-body.style-lotus h3::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 24px;
  background-image: url('/assets/img/ornaments/lotus-divider.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.65;
}

@media (max-width: 760px) {
  .content-body.style-lotus { padding: 48px 20px; }
}

/* ============================================================
   STYLE 3 — SACRED GEOMETRY WATERMARK
   Faint yantra mandala fills the background; text remains crisp.
   ============================================================ */
.content-body.style-yantra {
  padding: 48px 40px;
  background: var(--paper);
  border: 1px solid var(--frame-color);
  border-radius: 12px;
  position: relative;
  overflow: hidden;     /* contain the watermark within the rounded corners */
}

.content-body.style-yantra::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 90%);
  aspect-ratio: 1 / 1;
  background-image: url('/assets/img/ornaments/sri-yantra.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.07;        /* very faint — present, never distracting */
  pointer-events: none;
  z-index: 0;
}

/* Lift body content above the watermark */
.content-body.style-yantra > * {
  position: relative;
  z-index: 1;
}

/* Per-content-type watermark variants — operators can tune these.
   Mantra and stotra get the eight-petal yantra (more compact);
   katha and aarti keep the full Sri Yantra. */
.content-body.style-yantra[data-content-type="mantra"]::before,
.content-body.style-yantra[data-content-type="stotra"]::before {
  background-image: url('/assets/img/ornaments/eight-petal-yantra.svg');
}

@media (max-width: 760px) {
  .content-body.style-yantra { padding: 36px 22px; }
  .content-body.style-yantra::before { opacity: 0.05; }
}

/* ============================================================
   STYLE 6 — PAINTED MINIATURE HEADER
   Wide painted-miniature illustration banner above the body.
   The banner is rendered ABOVE .content-body via the container
   page's markup — see content.php.  This block styles the
   surrounding card.
   ============================================================ */
.content-body.style-miniature {
  padding: 40px 36px;
  background: var(--paper);
  border-radius: 0 0 12px 12px;
  border: 1px solid var(--frame-color);
  border-top: none;     /* the banner above provides the top edge */
  margin-top: 0;
  /* A subtle gold inner glow at the top of the body — visually
     bridges the painting above to the text below. */
  box-shadow: inset 0 12px 24px -16px rgba(201, 150, 43, 0.25);
}

/* The banner itself — a sibling element rendered just before
   .content-body.style-miniature in the markup. */
.content-miniature-banner {
  margin: 28px 0 0;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  position: relative;
  background: var(--ivory-warm);
  /* A 16:5 aspect ratio reads as a "banner" without dominating */
  aspect-ratio: 16 / 5;
  border: 1px solid var(--frame-color);
  border-bottom: none;
}
.content-miniature-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Subtle gradient at the bottom of the banner to ease into the body */
.content-miniature-banner::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to bottom, transparent, rgba(251, 246, 233, 0.6));
  pointer-events: none;
}

@media (max-width: 760px) {
  .content-body.style-miniature { padding: 30px 20px; }
  .content-miniature-banner {
    aspect-ratio: 16 / 6;     /* slightly taller on phones for legibility */
  }
}

/* ============================================================
   STYLE 7 — BRASS BOWL (short mantras only)
   Mantra rendered inside a circular brass-bowl frame with a
   soft inner glow.  Auto-falls back to Manuscript for content
   over 200 words (handled in PHP).
   ============================================================ */
.content-body.style-bowl {
  /* The body becomes a centered circle on desktop, a wide oval
     on mobile to accommodate the text width naturally. */
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, var(--paper) 0%, var(--ivory-warm) 70%, rgba(232, 181, 71, 0.15) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 40px;
  position: relative;
  /* The "brass" effect: outer gold ring + soft inner glow */
  box-shadow:
    0 0 0 1px var(--frame-color-strong),
    0 0 0 8px var(--paper),
    0 0 0 9px var(--frame-color),
    inset 0 0 60px rgba(232, 181, 71, 0.18),
    0 12px 36px -12px rgba(74, 21, 21, 0.18);
}

/* Brass-bowl typography — make the mantra the visual hero */
.content-body.style-bowl .lang-en,
.content-body.style-bowl .lang-hi {
  font-size: 1.4rem;
  line-height: 1.6;
  color: var(--maroon-deep);
}
.content-body.style-bowl .lang-hi {
  font-family: 'Tiro Devanagari Hindi', serif;
  font-size: 1.6rem;
}

/* Mobile — the circle becomes a soft-cornered rounded card so
   text isn't cramped by the curve at narrow widths. */
@media (max-width: 600px) {
  .content-body.style-bowl {
    aspect-ratio: auto;
    border-radius: 32px;
    padding: 40px 24px;
    min-height: 280px;
  }
}

/* ============================================================
   ACCESSIBILITY — focus rings preserved over decorated styles
   ============================================================ */
.content-body[class*="style-"] :focus-visible {
  outline: 2px solid var(--maroon);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ============================================================
   PRINT — strip decoration when printing devotionals for puja
   ============================================================ */
@media print {
  .content-body[class*="style-"] {
    background: white !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .content-body[class*="style-"]::before,
  .content-body[class*="style-"]::after,
  .content-miniature-banner {
    display: none !important;
  }
}

/* ============================================================
   REDUCED MOTION — none of the styles animate, but be explicit
   so any future ornament rotations / pulses respect it.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .content-body[class*="style-"]::before,
  .content-body[class*="style-"]::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================
   PER-PAGE LANGUAGE TOGGLE
   Sits just before the content body when both EN and HI are
   present.  Uses the existing data-set-lang JS handler in
   app.js — no new JavaScript required.  The active state and
   sliding thumb are driven entirely by the global
   html[data-lang="..."] attribute.
   ============================================================ */
.content-lang-switch {
  display: flex;
  align-items: center;
  justify-content: flex-start;     /* left-align to sit flush with eyebrow + headline */
  gap: 14px;
  margin: 0 0 22px;
  padding: 0;
}

.content-lang-switch-label {
  font-family: var(--display);
  color: var(--gold);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* The pill — relatively positioned so the thumb can slide inside it. */
.content-lang-switch-pill {
  position: relative;
  display: inline-flex;
  background: rgba(232, 217, 168, 0.25);          /* subtle gold-pale tint */
  border: 1px solid rgba(201, 150, 43, 0.35);
  border-radius: 999px;
  padding: 4px;
  box-shadow:
    inset 0 1px 2px rgba(74, 21, 21, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.6);              /* very subtle inner highlight */
}

/* The two buttons sit above the thumb. */
.content-lang-switch-pill .cls-btn {
  position: relative;
  z-index: 2;                                      /* above the thumb */
  appearance: none;
  background: transparent;
  border: 0;
  padding: 8px 22px;
  min-height: 36px;
  font-family: var(--display);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--maroon);
  cursor: pointer;
  border-radius: 999px;
  transition: color 0.22s var(--ease), transform 0.18s var(--ease);
  letter-spacing: 0.02em;
}
.content-lang-switch-pill .cls-btn:nth-child(2) {
  font-family: 'Tiro Devanagari Hindi', serif;
  font-size: 1.02rem;
}
.content-lang-switch-pill .cls-btn:hover {
  color: var(--maroon-deep);
}
.content-lang-switch-pill .cls-btn:active {
  transform: scale(0.97);
}

/* The sliding thumb — sits behind the buttons.  Two states driven
   by the document-level html[data-lang]: at "en" it occupies the
   left half, at "hi" it slides to the right half. */
.content-lang-switch-pill .cls-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  background: linear-gradient(135deg, var(--maroon-deep), var(--maroon));
  border-radius: 999px;
  z-index: 1;
  box-shadow:
    0 2px 6px -2px rgba(74, 21, 21, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Active state — text on top of the maroon thumb gets gold-pale. */
html[data-lang="en"] .content-lang-switch-pill .cls-btn[data-set-lang="en"],
html[data-lang="hi"] .content-lang-switch-pill .cls-btn[data-set-lang="hi"] {
  color: var(--gold-pale);
  font-weight: 600;
}

/* Slide the thumb when Hindi is active. */
html[data-lang="hi"] .content-lang-switch-pill .cls-thumb {
  left: calc(50% + 0px);                           /* move to right half */
}

/* Focus ring for keyboard nav */
.content-lang-switch-pill .cls-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 999px;
}

/* Reduced motion — replace the slide with an instant snap. */
@media (prefers-reduced-motion: reduce) {
  .content-lang-switch-pill .cls-thumb,
  .content-lang-switch-pill .cls-btn {
    transition: none !important;
  }
}

/* Mobile — keep the toggle compact but still tappable (44px minimum). */
@media (max-width: 600px) {
  .content-lang-switch {
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
  }
  .content-lang-switch-label {
    font-size: 0.66rem;
    letter-spacing: 0.14em;
  }
  .content-lang-switch-pill .cls-btn {
    padding: 8px 18px;
    font-size: 0.88rem;
    min-height: 40px;                              /* slightly bigger tap target */
  }
}

/* The toggle uses .lang-en / .lang-hi spans for its own label.
   Make sure those still respect the global hide rule. */
.content-lang-switch-label .lang-en,
.content-lang-switch-label .lang-hi {
  display: inline;
}
html[data-lang="hi"] .content-lang-switch-label .lang-en,
html[data-lang="en"] .content-lang-switch-label .lang-hi {
  display: none;
}

/* Print — hide the toggle (printed page only carries one language anyway). */
@media print {
  .content-lang-switch { display: none !important; }
}

/* ============================================================
   GLOBAL HINDI SIZING
   Devanagari glyphs run visually smaller than Latin at the same
   point size — strokes, conjuncts, and the headline mark
   (शिरोरेखा) need a touch more room to read comfortably.
   When the user is in Hindi mode, nudge the entire page up by
   ~6%.  This is a single rule (no compounding inside nested
   Hindi elements) and only applies when reading Hindi.
   ============================================================ */
html[data-lang="hi"] body {
  font-size: 106%;
}

/* For elements that explicitly use the Hindi font even in EN
   mode (e.g. the .hi-sub eyebrow, the language toggle's HI
   button label), bump them slightly too. */
.lang-hi,
.hi-sub,
[class*="hi-title"],
[class*="hi-name"],
.brand .hi,
.cat-card .hi,
.feat-card .hi,
.fest-card .hi,
.shloka-content .hi-title,
.feat-main .hi-title,
.panchang-card .date-hi,
.panchang-card .row .v.hi {
  font-size: 1.05em;       /* relative — only adds ~5% on top of the parent */
  line-height: 1.55;
}

/* ============================================================
   LANGUAGE FALLBACK
   When a piece of content exists in only one language, the
   server emits the text inside a `.lang-fallback` span/div
   instead of `.lang-en` / `.lang-hi`.  This class is NEVER
   hidden by the toggle rules in main.css, so the available
   language always shows regardless of the user's chosen mode.
   See _partials/bilingual.php for the rendering helpers.
   ============================================================ */
.lang-fallback {
  /* Inherits parent display naturally (inline for spans, block
     for divs).  Always visible — never controlled by data-lang. */
}

/* Optional fallback hint — a tiny italic note appears when fallback
   kicks in.  Set via a `data-fallback-hint` attribute on the parent
   if you want to opt in to the hint per-element.  Off by default to
   keep the design clean — most users won't need or want the noise. */
[data-fallback-hint] > .lang-fallback::before {
  content: "(only one language available)";
  display: block;
  font-size: 0.72rem;
  color: var(--ink-mute);
  font-style: italic;
  margin-bottom: 6px;
}
