/* ==========================================================================
   WE — Whole Existence — stylesheet
   Plain CSS, no build step. Custom properties drive light/dark theming.
   ========================================================================== */

:root {
  --paper: #f6f2ea;
  --paper-raised: #efe9dd;
  --ink: #1b1815;
  --ink-muted: #6e665c;
  --hairline: #e3dbcc;
  --accent: #8b5a2e;
  --accent-soft: #f0e2d1;
  --accent-ink: #ffffff;
  --font-scale: 1;
  --font-ui: "Instrument Sans", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-reading: "Newsreader", "Tiro Devanagari Hindi", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

html.dark {
  --paper: #1a1714;
  --paper-raised: #221e19;
  --ink: #ede6da;
  --ink-muted: #9c948a;
  --hairline: #322c25;
  --accent: #c89055;
  --accent-soft: #33281a;
  --accent-ink: #1a1714;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

::selection {
  background: var(--accent-soft);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------- layout shell ------------------------ */

.site-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hairline);
}

.header-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.brand-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.nav-link {
  font-size: 0.875rem;
  color: var(--ink-muted);
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--ink);
}

.nav-link.active {
  color: var(--accent);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--hairline);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 0.25rem;
  font-size: 0.68rem;
  color: var(--ink-muted);
  text-align: center;
}

.bottom-nav a.active {
  color: var(--accent);
}

.nav-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: transparent;
}

.bottom-nav a.active .nav-dot {
  background: var(--accent);
}

main {
  flex: 1;
  padding-bottom: 6rem;
}

@media (min-width: 768px) {
  .site-header {
    display: block;
  }
  .bottom-nav {
    display: none;
  }
  main {
    padding-bottom: 4rem;
  }
}

/* ---------------------------------- content column ----------------------- */

.content-column {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.reading-column {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 3.5rem;
}

@media (min-width: 768px) {
  .reading-column {
    padding: 3.5rem 1.5rem;
  }
}

/* ---------------------------------- typography --------------------------- */

h1,
h2,
h3 {
  margin: 0;
  font-weight: 500;
}

.font-reading {
  font-family: var(--font-reading);
}

.reading-prose {
  font-family: var(--font-reading);
  font-size: calc(1.125rem * var(--font-scale));
  line-height: 1.9;
}

.reading-prose p {
  margin: 0 0 1.25rem;
}

.reading-prose p:last-child {
  margin-bottom: 0;
}

:lang(hi),
:lang(mr) {
  line-height: 1.75;
}

.reading-prose:lang(hi),
.reading-prose:lang(mr) {
  line-height: 2.05;
}

@media (min-width: 768px) {
  .reading-prose {
    font-size: calc(1.1875rem * var(--font-scale));
  }
}

.text-muted {
  color: var(--ink-muted);
}

.text-accent {
  color: var(--accent);
}

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

.eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

/* ---------------------------------- hero ---------------------------------- */

.hero {
  max-width: 42rem;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 2.5rem;
  text-align: center;
}

@media (min-width: 768px) {
  .hero {
    padding: 5rem 1.5rem 2.5rem;
  }
}

.hero-kicker {
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.hero-title {
  font-family: var(--font-reading);
  font-size: 2.5rem;
  margin-top: 0.25rem;
}

@media (min-width: 768px) {
  .hero-title {
    font-size: 3rem;
  }
}

.hero-tagline {
  margin-top: 1rem;
  color: var(--ink-muted);
}

.hero-lines {
  font-family: var(--font-reading);
  font-size: 1.125rem;
  line-height: 1.7;
  margin-top: 1.5rem;
}

.hero-actions {
  margin-top: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

/* ---------------------------------- buttons / chips ----------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  background: var(--ink);
  color: var(--paper);
  transition: opacity 0.15s ease;
}

.btn:hover {
  opacity: 0.9;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-link {
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.btn-link:hover {
  color: var(--ink);
}

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.875rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip-static {
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------------------------------- cards / sections ----------------------- */

section {
  margin: 3rem 0;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.section-heading h2 {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.card {
  display: block;
  border: 1px solid var(--hairline);
  border-radius: 0.65rem;
  padding: 1.25rem;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--accent);
}

.card-title {
  font-family: var(--font-reading);
  font-size: 1.25rem;
}

.card-meta {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.card-cta {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--accent);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: repeat(4, 1fr);
  }
}

.tile {
  display: block;
  text-align: center;
  border: 1px solid var(--hairline);
  border-radius: 0.5rem;
  padding: 0.85rem 0.5rem;
  font-size: 0.875rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.tile:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------------------------------- TOC / row list -------------------------- */

.row-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.row-list li {
  border-bottom: 1px solid var(--hairline);
}

.row-list li:last-child {
  border-bottom: none;
}

.row-list a,
.row-item {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  padding: 1.5rem 0;
}

.row-number {
  font-family: var(--font-reading);
  color: var(--ink-muted);
  width: 2rem;
  flex-shrink: 0;
}

.row-body {
  flex: 1;
}

.row-title {
  font-family: var(--font-reading);
  font-size: 1.25rem;
  display: block;
  transition: color 0.15s ease;
}

.row-list a:hover .row-title {
  color: var(--accent);
}

.row-summary {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.row-meta {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.day-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  font-size: 0.75rem;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.day-badge.done {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.day-badge.today {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------------------------------- progress bar ---------------------------- */

.progress-bar {
  height: 4px;
  width: 100%;
  border-radius: 999px;
  background: var(--paper-raised);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* ---------------------------------- toolbar --------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.25rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.toolbar button:hover {
  color: var(--ink);
}

.toolbar button.active-state {
  color: var(--accent);
}

.sticky-progress {
  position: sticky;
  top: 4rem;
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(6px);
  padding: 0.75rem 0;
  margin: 0.5rem -1.5rem 0;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

@media (min-width: 768px) {
  .sticky-progress {
    top: 5rem;
  }
}

/* ---------------------------------- reference marks -------------------------- */

.ref-mark {
  color: var(--accent);
  font-size: 0.7em;
  vertical-align: super;
  margin: 0 0.1rem;
}

.ref-mark:hover {
  text-decoration: underline;
}

/* ---------------------------------- reference panel / drawer / sheet --------- */

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(27, 24, 21, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.panel-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.ref-panel {
  position: fixed;
  z-index: 50;
  background: var(--paper);
  border: 1px solid var(--hairline);
  transition: transform 0.3s ease;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 82vh;
  border-radius: 1.1rem 1.1rem 0 0;
  border-bottom: none;
  transform: translateY(100%);
  overflow-y: auto;
}

.ref-panel.open {
  transform: translateY(0);
}

@media (min-width: 768px) {
  .ref-panel {
    left: auto;
    top: 0;
    bottom: 0;
    width: 380px;
    max-height: none;
    border-radius: 0;
    border-left: 1px solid var(--hairline);
    border-top: none;
    transform: translateX(100%);
  }
  .ref-panel.open {
    transform: translateX(0);
  }
}

.ref-panel-inner {
  padding: 1.5rem;
}

.ref-panel-close {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.ref-panel-close:hover {
  color: var(--ink);
}

.ref-panel-actions {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  border-top: 1px solid var(--hairline);
  padding-top: 1rem;
  font-size: 0.875rem;
}

/* ---------------------------------- language modal ---------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(27, 24, 21, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-box {
  width: 100%;
  max-width: 24rem;
  border-radius: 0.65rem;
  border: 1px solid var(--hairline);
  background: var(--paper);
  padding: 2rem;
  text-align: center;
}

.modal-choice {
  display: block;
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 0.5rem;
  padding: 0.65rem;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.modal-choice:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------------------------------- dropdown menus ----------------------------- */

.dropdown {
  position: relative;
}

.dropdown-trigger {
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.dropdown-trigger:hover {
  color: var(--ink);
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 8rem;
  border: 1px solid var(--hairline);
  background: var(--paper);
  border-radius: 0.4rem;
  padding: 0.25rem 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  z-index: 40;
  display: none;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.9rem;
  font-size: 0.875rem;
}

.dropdown-menu button:hover {
  background: var(--paper-raised);
}

.dropdown-menu button.selected {
  color: var(--accent);
}

/* ---------------------------------- search input ------------------------------- */

.search-input {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 0.5rem;
  background: transparent;
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  color: var(--ink);
}

.search-input::placeholder {
  color: var(--ink-muted);
}

.search-input:focus {
  border-color: var(--accent);
}

.search-results {
  margin-top: 0.75rem;
  border: 1px solid var(--hairline);
  border-radius: 0.5rem;
  overflow: hidden;
  list-style: none;
  padding: 0;
}

.search-results li + li {
  border-top: 1px solid var(--hairline);
}

.search-results a {
  display: block;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

.search-results a:hover {
  background: var(--paper-raised);
}

/* ---------------------------------- karma highlight box ------------------------- */

.karma-box {
  border-radius: 0.65rem;
  background: var(--accent-soft);
  padding: 1.25rem;
}

.karma-box .eyebrow {
  color: var(--accent);
}

.source-link-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.source-link {
  border: 1px solid var(--hairline);
  border-radius: 0.4rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.875rem;
  transition: border-color 0.15s ease;
}

.source-link:hover {
  border-color: var(--accent);
}

/* ---------------------------------- you page stats ------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  text-align: center;
}

.stat-box {
  border: 1px solid var(--hairline);
  border-radius: 0.65rem;
  padding: 1rem;
}

.stat-value {
  font-family: var(--font-reading);
  font-size: 1.5rem;
}

.stat-label {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.pref-group {
  margin-top: 1.25rem;
}

.pref-options {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pref-btn {
  border: 1px solid var(--hairline);
  border-radius: 0.4rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.875rem;
  text-transform: capitalize;
}

.pref-btn.selected {
  border-color: var(--accent);
  color: var(--accent);
}

.library-rows {
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.library-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--hairline);
}

.library-row:last-child {
  border-bottom: none;
}

/* ---------------------------------- misc utilities ------------------------------- */

.hidden {
  display: none !important;
}

.whitespace-pre {
  white-space: pre-line;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.border-t {
  border-top: 1px solid var(--hairline);
  padding-top: 1.25rem;
}

.chapter-nav {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-top: 3.5rem;
  border-top: 1px solid var(--hairline);
  padding-top: 1.5rem;
  font-size: 0.875rem;
  gap: 1rem;
}

.chapter-nav .to-title {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: 0.15rem;
}

.chapter-nav .next-link {
  text-align: right;
  color: var(--accent);
}

.status-tag {
  font-size: 0.75rem;
  color: var(--ink-muted);
}
