/* ==========================================================================
   Shri Parasara Vidhya Peetam — "Temple Manuscript" design system
   Deep maroon + gold on warm parchment, inspired by South Indian temple
   architecture and palm-leaf manuscript borders. Self-hosted Catamaran
   (display/UI, Tamil+Latin) and Noto Sans Tamil (long-form Tamil body copy).
   ========================================================================== */

@font-face {
  font-family: 'Catamaran';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/assets/fonts/catamaran-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: 'Catamaran';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/assets/fonts/catamaran-tamil.woff2') format('woff2');
  unicode-range: U+0964-0965, U+0B82-0BFA, U+200C-200D, U+20B9, U+25CC;
}
@font-face {
  font-family: 'Noto Sans Tamil';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/fonts/notosanstamil-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: 'Noto Sans Tamil';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/fonts/notosanstamil-tamil.woff2') format('woff2');
  unicode-range: U+0964-0965, U+0B82-0BFA, U+200C-200D, U+20B9, U+25CC;
}

:root {
  /* Palette */
  --brand: #7A1F2E;
  --brand-dark: #4E1119;
  --brand-light: #9C3B4C;
  --gold: #B07F26;
  --gold-light: #D9AE56;
  --parchment: #FAF2E1;
  --surface: #FFFDF8;
  --ink: #2A1B12;
  --ink-muted: #71604E;
  --border: #E6D7B3;
  --border-strong: #D8C293;
  --success-bg: #E7F1E1;
  --success-ink: #33602A;
  --error-bg: #FAEAEA;
  --error-ink: #8A2424;

  /* Shadows — tinted warm, never pure gray */
  --shadow-sm: 0 1px 3px rgba(90, 42, 20, 0.09), 0 1px 2px rgba(90, 42, 20, 0.06);
  --shadow-md: 0 6px 20px -4px rgba(90, 42, 20, 0.16), 0 2px 6px rgba(90, 42, 20, 0.08);
  --shadow-gold: 0 8px 24px -6px rgba(176, 127, 38, 0.35);

  /* Type */
  --font-ui: 'Catamaran', 'Noto Sans Tamil', -apple-system, Segoe UI, sans-serif;
  --font-content: 'Noto Sans Tamil', 'Catamaran', sans-serif;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--parchment);
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

h1, h2, h3, h4 {
  font-family: var(--font-ui);
  font-weight: 800;
  line-height: 1.35;
  color: var(--ink);
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.8rem, 1.5rem + 1.4vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 1.2rem + 0.9vw, 1.85rem); }
h3 { font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.4rem); font-weight: 700; }
h4 { font-size: 1.08rem; font-weight: 700; }

.icon {
  width: 1.1em;
  height: 1.1em;
  stroke: currentColor;
  fill: none;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

/* ---------- Layout ---------- */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Kolam-inspired dot-and-diamond divider strip */
.kolam-divider {
  height: 10px;
  background-image:
    radial-gradient(circle, var(--gold) 1.4px, transparent 1.6px);
  background-size: 22px 10px;
  background-position: center;
  opacity: 0.55;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.site-header .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 16px;
}
.brand {
  font-size: clamp(1rem, 0.78rem + 0.85vw, 1.32rem);
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 11px;
  line-height: 1.25;
}
.brand .brand-mark {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold-light);
  box-shadow: var(--shadow-sm);
}
.brand:hover { color: var(--brand-dark); }

.nav-links {
  display: flex;
  gap: 22px;
  align-items: center;
}
.nav-links a:not(.cta) {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.96rem;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}
.nav-links a:not(.cta):hover { color: var(--brand); border-bottom-color: var(--gold); }
.nav-links a.cta,
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand);
  background-image: linear-gradient(155deg, var(--brand-light), var(--brand));
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.nav-links a.cta:hover,
.btn:hover {
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn:active { transform: translateY(0); }
.btn-block { width: 100%; justify-content: center; }
.btn-ghost {
  background: transparent;
  background-image: none;
  color: var(--ink);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--parchment); color: var(--ink); box-shadow: none; }
.btn-danger-ghost { color: var(--error-ink); border-color: #E8C6C6; }

.nav-toggle { display: none; }
.nav-toggle-label {
  display: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.nav-toggle-label:hover { background: var(--parchment); }
.nav-toggle-label .icon { width: 26px; height: 26px; }

main { padding: 44px 0 72px; min-height: 55vh; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 36px;
  color: var(--ink-muted);
  font-size: 0.88rem;
  text-align: center;
  background: var(--surface);
}

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 30px;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 7px; font-weight: 700; font-size: 0.92rem; color: var(--ink); }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(176, 127, 38, 0.15);
}

.auth-shell { max-width: 440px; margin: 0 auto; }
.auth-shell .card { position: relative; overflow: hidden; padding-top: 36px; }
.auth-shell .card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--brand), var(--gold), var(--brand));
}
.auth-shell h1 { text-align: center; margin-bottom: 6px; }
.auth-shell .subtitle { text-align: center; color: var(--ink-muted); font-size: 0.92rem; margin-bottom: 26px; }

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.94rem;
  font-weight: 600;
}
.flash-error { background: var(--error-bg); color: var(--error-ink); }
.flash-success { background: var(--success-bg); color: var(--success-ink); }

.hint { color: var(--ink-muted); font-size: 0.89rem; margin-top: 8px; }

/* ---------- Feed / posts ---------- */
.feed-header {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 22px;
}
.feed-header h1 { margin: 0 0 4px; }
.search-form { display: flex; gap: 8px; }
.search-form input {
  padding: 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  min-width: 220px;
  background: var(--surface);
  font-family: inherit;
}
.search-form input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(176,127,38,0.15); }
.search-form button { border-radius: 999px; }

.category-chips { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 30px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.chip:hover { border-color: var(--gold); color: var(--brand); }
.chip-active, .chip-active:hover {
  background: var(--brand);
  background-image: linear-gradient(155deg, var(--brand-light), var(--brand));
  color: #fff;
  border-color: var(--brand);
}
.chip-count { opacity: 0.7; font-size: 0.85em; font-weight: 600; }

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 26px;
  margin-bottom: 36px;
}
/* Break the grid: first card on the home feed spans full width as a featured item */
.post-grid > a:first-child {
  grid-column: 1 / -1;
}
.post-grid > a:first-child .post-card-body { padding: 30px 34px; }
.post-grid > a:first-child h3 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.7rem); }

.post-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  opacity: 0;
  transform: translateY(14px);
  transition: transform 220ms ease, box-shadow 220ms ease, opacity 500ms ease, border-color 220ms ease;
}
.post-card.is-visible { opacity: 1; transform: translateY(0); }
.post-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--gold-light);
  transform: translateY(-3px);
}
.post-card-image {
  height: 170px;
  background-size: cover;
  background-position: center;
  background-color: var(--border);
}
.post-card-body { padding: 22px; }
.post-card-body h3 {
  margin: 0 0 10px;
  font-size: 1.14rem;
  font-family: var(--font-content);
  font-weight: 700;
  line-height: 1.5;
}
.post-card-body p {
  margin: 0 0 12px;
  color: var(--ink-muted);
  font-size: 0.93rem;
  font-family: var(--font-content);
  line-height: 1.65;
}
.post-card-date {
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pagination { display: flex; justify-content: center; align-items: center; gap: 22px; margin: 28px 0; }
.pagination a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
}
.pagination a:hover { border-color: var(--gold); background: var(--surface); }
.pagination-status { color: var(--ink-muted); font-size: 0.88rem; font-weight: 600; }

/* ---------- Post detail ---------- */
.post-detail { max-width: 760px; margin: 0 auto; }
.post-detail h1 {
  margin-bottom: 12px;
  font-family: var(--font-content);
  line-height: 1.45;
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.post-featured-image { width: 100%; border-radius: var(--radius); margin-bottom: 28px; box-shadow: var(--shadow-sm); }
.video-embed { position: relative; padding-bottom: 56.25%; height: 0; margin-bottom: 28px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.video-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

.post-body {
  font-family: var(--font-content);
  font-size: 1.09rem;
  line-height: 1.95;
  color: var(--ink);
}
.post-body p { margin: 0 0 1.25em; }
.post-body h2, .post-body h3, .post-body h4 {
  font-family: var(--font-content);
  margin: 1.5em 0 0.65em;
  color: var(--brand-dark);
}
.post-body h3 { padding-left: 16px; border-left: 4px solid var(--gold); }
.post-body ul, .post-body ol { margin: 0 0 1.25em; padding-left: 1.4em; }
.post-body li { margin-bottom: 0.55em; }
.post-body blockquote {
  margin: 1.8em 0;
  padding: 22px 26px;
  background: var(--parchment);
  border: 1px solid var(--border);
  border-left: 5px solid var(--brand);
  border-radius: var(--radius-sm);
  font-style: normal;
  position: relative;
}
.post-body blockquote p { margin: 0; color: var(--brand-dark); }
.post-body blockquote::before {
  content: '\201C';
  position: absolute;
  top: -6px;
  left: 16px;
  font-size: 3rem;
  font-family: Georgia, serif;
  color: var(--gold-light);
  line-height: 1;
}
.post-body a { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }

/* End-of-article kolam flourish */
.post-end-motif { display: flex; justify-content: center; margin: 44px 0 8px; opacity: 0.75; }
.post-end-motif svg { width: 46px; height: 46px; color: var(--gold); }

/* ---------- Q&A ---------- */
.qna-item { margin-bottom: 20px; }
.qna-question { margin-bottom: 14px; }
.qna-asker {
  font-weight: 700;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}
.qna-question p, .qna-answer p { margin: 0; font-family: var(--font-content); line-height: 1.75; }
.qna-answer {
  background: var(--parchment);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  border-left: 4px solid var(--gold);
}
.qna-answer-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 8px;
}
.qna-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--parchment);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.badge-draft { background: #F0E6CE; color: #7A5A1E; }
.badge-published { background: var(--success-bg); color: var(--success-ink); }

/* ---------- Admin ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px;
  background: linear-gradient(185deg, var(--brand-dark), #33090F);
  color: #fff;
  padding: 26px 18px;
  flex-shrink: 0;
}
.admin-sidebar .brand { color: #fff; margin-bottom: 30px; }
.admin-sidebar .brand .brand-mark { color: var(--gold-light); }
.admin-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #E9D9C4;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  margin-bottom: 3px;
  font-weight: 600;
  font-size: 0.94rem;
  transition: background 150ms ease, color 150ms ease;
}
.admin-sidebar nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.admin-sidebar nav a.active { background: rgba(255,255,255,0.14); color: #fff; }
.admin-main { flex: 1; padding: 34px 42px; max-width: 1180px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; gap: 16px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
  margin-top: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-card .stat-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  background: linear-gradient(155deg, var(--gold-light), var(--gold));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-gold);
  flex-shrink: 0;
}
.stat-card .stat-icon .icon { width: 22px; height: 22px; }
.stat-card .stat-label { color: var(--ink-muted); font-size: 0.85rem; font-weight: 600; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 800; color: var(--ink); line-height: 1.2; }

/* ---------- Admin tables / forms ---------- */
.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.admin-table th, .admin-table td { text-align: left; padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table th { background: var(--parchment); font-weight: 700; color: var(--brand-dark); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.admin-table tr:hover td { background: rgba(176, 127, 38, 0.05); }
.admin-row-actions { display: flex; gap: 14px; align-items: center; }
.link-btn { display: inline-flex; align-items: center; gap: 4px; background: none; border: none; color: var(--brand); font-weight: 700; cursor: pointer; padding: 0; font-size: 0.89rem; }
.link-btn:hover { color: var(--brand-dark); text-decoration: underline; }
.link-btn-danger { color: var(--error-ink); }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.checkbox-item { display: flex; align-items: center; gap: 7px; font-weight: 500; font-size: 0.92rem; }
.checkbox-item input { width: auto; }

.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

/* ---------- Scroll reveal (Tier 1 motion) ---------- */
@media (prefers-reduced-motion: reduce) {
  .post-card { opacity: 1 !important; transform: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .nav-toggle-label { display: inline-flex; }
  .nav-links {
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    flex-direction: column;
    align-items: stretch;
    padding: 10px 20px 18px;
    gap: 4px;
    display: none;
  }
  .nav-links a:not(.cta) { padding: 11px 4px; border-bottom: 1px solid var(--border); }
  .nav-links a.cta { margin-top: 8px; justify-content: center; }
  .nav-toggle:checked ~ .nav-links { display: flex; }

  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; display: flex; align-items: center; gap: 4px; overflow-x: auto; padding: 14px 16px; }
  .admin-sidebar .brand { margin-bottom: 0; margin-right: 8px; white-space: nowrap; }
  .admin-sidebar nav { display: flex; gap: 2px; }
  .admin-sidebar nav a { white-space: nowrap; padding: 8px 11px; }
  .admin-main { padding: 24px 18px; }

  .book-detail { grid-template-columns: 1fr; }
}

/* ---------- Share buttons ---------- */
.share-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin: 24px 0 32px;
  padding: 16px 20px;
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.share-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
}
.share-label .icon { width: 16px; height: 16px; }
.share-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.share-btn svg { width: 18px; height: 18px; margin: auto; }
.share-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); border-color: transparent; }
.share-whatsapp:hover { background: #25D366; color: #fff; }
.share-facebook:hover { background: #1877F2; color: #fff; }
.share-twitter:hover { background: #000; color: #fff; }
.share-telegram:hover { background: #26A5E4; color: #fff; }
.share-linkedin:hover { background: #0A66C2; color: #fff; }
.share-email:hover { background: var(--brand); color: #fff; }
.share-copy {
  width: auto;
  border-radius: 999px;
  padding: 0 16px 0 14px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
}
.share-copy:hover { background: var(--gold); color: #fff; }
.share-copy.share-copied { background: var(--success-bg); border-color: var(--success-ink); color: var(--success-ink); }