/* Thirukkural — Styles */

:root {
  --font-tamil: 'Noto Serif Tamil', serif;
  --font-english: 'Source Serif 4', Georgia, serif;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme (default) */
html.theme-light {
  color-scheme: light;
  --color-bg: #f1f5f9;
  --color-bg-alt: #e2e8f0;
  --color-surface: #ffffff;
  --color-surface-elevated: #ffffff;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-accent: #6366f1;
  --color-accent-hover: #4f46e5;
  --color-border: rgba(148, 163, 184, 0.3);
  --color-focus: #6366f1;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.5);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
}

/* Dark theme */
html.theme-dark {
  color-scheme: dark;
  background-color: #0c0f14;
  --color-bg: #0c0f14;
  --color-bg-alt: #141922;
  --color-surface: #1a1f2e;
  --color-surface-elevated: #222938;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-accent: #a78bfa;
  --color-accent-hover: #c4b5fd;
  --color-border: rgba(148, 163, 184, 0.12);
  --color-focus: #a78bfa;
  --glass-bg: rgba(26, 31, 46, 0.8);
  --glass-border: rgba(148, 163, 184, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.45), 0 8px 10px -6px rgba(0, 0, 0, 0.35);
}

/* Sepia theme */
html.theme-sepia {
  color-scheme: light;
  --color-bg: #f5f0e6;
  --color-bg-alt: #ebe4d6;
  --color-surface: #fdfbf7;
  --color-surface-elevated: #ffffff;
  --color-text: #2d2a24;
  --color-text-muted: #6b6358;
  --color-accent: #b45309;
  --color-accent-hover: #92400e;
  --color-border: rgba(107, 99, 88, 0.25);
  --color-focus: #b45309;
  --glass-bg: rgba(253, 251, 247, 0.85);
  --glass-border: rgba(212, 201, 176, 0.5);

  --shadow-sm: 0 1px 2px rgba(45, 42, 36, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(45, 42, 36, 0.08), 0 2px 4px -2px rgba(45, 42, 36, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(45, 42, 36, 0.1), 0 4px 6px -4px rgba(45, 42, 36, 0.06);
  --shadow-xl: 0 20px 25px -5px rgba(45, 42, 36, 0.1), 0 8px 10px -6px rgba(45, 42, 36, 0.06);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0ms;
    --transition-normal: 0ms;
  }

  .chapter-card:hover,
  .chapter-card:focus,
  .kural-preview:hover,
  .kural-preview:focus,
  .kural-prev:hover,
  .kural-next:hover,
  .kural-jump-form button:hover,
  .shortcuts-close:hover,
  .shortcuts-trigger:hover {
    transform: none;
  }
}

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

button,
a,
[role="button"],
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  font-family: var(--font-english);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text);
  background-color: var(--color-bg, #f1f5f9);
  min-height: 100vh;
  position: relative;
}

/* Theme-specific body backgrounds (use longhand to avoid shorthand reset) */
html.theme-light body {
  background-color: #f1f5f9;
  background-image: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
}

html.theme-dark body {
  background-color: #0c0f14;
  background-image: linear-gradient(180deg, #0f1419 0%, #0c0f14 50%, #080b0f 100%);
}

html.theme-sepia body {
  background-color: #f5f0e6;
  background-image: linear-gradient(180deg, #faf8f4 0%, #f5f0e6 50%, #ebe4d6 100%);
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 100;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-md);
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Header */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.theme-toggle {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--color-bg-alt);
  border-radius: var(--radius-full);
}

.theme-btn {
  padding: var(--space-xs) var(--space-sm);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  font-family: var(--font-english);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-btn:hover {
  color: var(--color-text);
}

.theme-btn.active {
  background: var(--color-surface);
  color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.theme-btn:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-xl);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.site-title {
  margin: 0;
  text-align: center;
  flex: 1;
}

.site-title a {
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.tamil-title {
  display: block;
  font-family: var(--font-tamil);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-text);
}

.english-title {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.shortcuts-trigger {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: var(--radius-full);
  background: var(--color-bg-alt);
  font-size: 1.25rem;
  font-family: var(--font-english);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.shortcuts-trigger:hover,
.shortcuts-trigger:focus {
  background: var(--color-accent);
  color: white;
  transform: scale(1.05);
  outline: none;
}

.shortcuts-trigger:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Layout */
.app-layout {
  display: grid;
  grid-template-columns: 1fr;
  min-height: calc(100vh - 80px);
}

/* Sidebar — hidden on desktop, drawer on mobile */
.sidebar {
  display: none;
}

.sidebar-toggle {
  display: none;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  font-size: 1.25rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--color-border);
}

.sidebar-toggle:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* (media queries moved to end of file, before animations) */

.loading-nav {
  color: var(--color-text-muted);
  font-style: italic;
}

.nav-section {
  margin-bottom: var(--space-lg);
}

.nav-section-title {
  display: block;
  font-family: var(--font-english);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-accent);
  text-decoration: none;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-sm);
  transition: color var(--transition-fast);
}

.nav-section-title:hover,
.nav-section-title:focus {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.nav-section-title:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.nav-section-title .tamil-title {
  display: none;
}

.nav-group-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: var(--space-md) 0 var(--space-xs);
}

.nav-chapters {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-chapter {
  font-family: var(--font-english);
  font-size: 0.9rem;
  color: var(--color-text);
  text-decoration: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-chapter:hover,
.nav-chapter:focus {
  background: var(--color-surface);
  color: var(--color-accent);
  padding-left: calc(var(--space-md) + 4px);
}

.nav-chapter:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 1px;
}

/* Main content */
.main-content {
  padding: var(--space-xl);
  max-width: 120ch;
  margin: 0 auto;
}

.loading-state {
  padding: var(--space-2xl);
  text-align: center;
  color: var(--color-text-muted);
}

.content-area {
  min-height: 200px;
}

/* Home view */
.home-hero {
  text-align: center;
  padding: var(--space-2xl) 0 var(--space-xl);
}

.hero-title {
  margin: 0;
  font-family: var(--font-tamil);
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  margin: var(--space-xs) 0 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.hero-tagline {
  margin: var(--space-sm) 0 0;
  font-size: 1.05rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.home-sections {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.section-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-xs);
  padding: var(--space-xl) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.section-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--section-accent);
  opacity: 0.8;
  transition: height var(--transition-normal);
}

.section-card:hover,
.section-card:focus {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: transparent;
}

.section-card:hover::before,
.section-card:focus::before {
  height: 6px;
}

.section-card:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.section-card--virtue {
  --section-accent: linear-gradient(90deg, #6366f1, #818cf8);
}

.section-card--wealth {
  --section-accent: linear-gradient(90deg, #059669, #34d399);
}

.section-card--love {
  --section-accent: linear-gradient(90deg, #e11d48, #fb7185);
}

html.theme-dark .section-card--virtue {
  --section-accent: linear-gradient(90deg, #818cf8, #a78bfa);
}

html.theme-dark .section-card--wealth {
  --section-accent: linear-gradient(90deg, #34d399, #6ee7b7);
}

html.theme-dark .section-card--love {
  --section-accent: linear-gradient(90deg, #fb7185, #fda4af);
}

html.theme-sepia .section-card--virtue {
  --section-accent: linear-gradient(90deg, #b45309, #d97706);
}

html.theme-sepia .section-card--wealth {
  --section-accent: linear-gradient(90deg, #047857, #059669);
}

html.theme-sepia .section-card--love {
  --section-accent: linear-gradient(90deg, #be123c, #e11d48);
}

.section-card-icon {
  font-size: 1.75rem;
  margin-bottom: var(--space-xs);
}

.section-card-name {
  font-size: 1.15rem;
  font-weight: 600;
}

.section-card-tamil {
  font-family: var(--font-tamil);
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

.section-card-count {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.home-search {
  text-align: center;
  padding-bottom: var(--space-xl);
}

.home-search-label {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-sm);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.kural-jump-form {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  justify-content: center;
}

.kural-jump-form label {
  font-weight: 500;
}

.kural-jump-form input {
  width: 10ch;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-family: var(--font-english);
  font-size: 1rem;
  background: var(--color-surface);
  text-align: center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.kural-jump-form input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

html.theme-dark .kural-jump-form input:focus {
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.2);
}

.kural-jump-form button {
  padding: var(--space-sm) var(--space-xl);
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-english);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.kural-jump-form button:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.kural-jump-form button:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* View header */
.view-header {
  margin-bottom: var(--space-xl);
}

.view-header h2 {
  margin: 0 0 var(--space-sm);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.view-header h2 span[lang="ta"] {
  font-family: var(--font-tamil);
  font-weight: 500;
  font-size: 1rem;
  color: var(--color-text-muted);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-english);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
  list-style: none;
  padding: 0;
}

.breadcrumb-sep {
  font-size: 0.7em;
  opacity: 0.5;
  user-select: none;
}

.breadcrumb a {
  color: var(--color-accent);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.breadcrumb a:hover {
  color: var(--color-accent-hover);
  background: rgba(99, 102, 241, 0.08);
}

html.theme-dark .breadcrumb a:hover {
  background: rgba(167, 139, 250, 0.1);
}

html.theme-sepia .breadcrumb a:hover {
  background: rgba(180, 83, 9, 0.08);
}

.section-meta,
.chapter-meta {
  margin: 0;
  font-family: var(--font-english);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Section view - chapter grid */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
}

.chapter-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.chapter-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), transparent);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.chapter-card:hover,
.chapter-card:focus {
  box-shadow: var(--shadow-lg);
  border-color: transparent;
  transform: translateY(-3px);
}

.chapter-card:hover::before,
.chapter-card:focus::before {
  opacity: 1;
}

.chapter-card:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.chapter-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-english);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-accent);
  background: rgba(99, 102, 241, 0.12);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-sm);
  width: fit-content;
  letter-spacing: 0.02em;
}

html.theme-dark .chapter-num {
  background: rgba(167, 139, 250, 0.2);
}

html.theme-sepia .chapter-num {
  background: rgba(180, 83, 9, 0.15);
}

.chapter-name {
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.chapter-tamil {
  font-family: var(--font-tamil);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.chapter-range {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Chapter view - kural list */
.kural-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.kural-preview {
  position: relative;
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: var(--space-md);
  padding: var(--space-lg);
  padding-left: calc(var(--space-lg) + 4px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-normal);
}

.kural-preview::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.kural-preview:hover,
.kural-preview:focus {
  box-shadow: var(--shadow-md);
  border-color: transparent;
  transform: translateX(4px);
}

.kural-preview:hover::before,
.kural-preview:focus::before {
  opacity: 1;
}

.kural-preview:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.kural-preview-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.1);
  font-family: var(--font-english);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--color-accent);
}

html.theme-dark .kural-preview-num {
  background: rgba(167, 139, 250, 0.15);
}

html.theme-sepia .kural-preview-num {
  background: rgba(180, 83, 9, 0.1);
}

.kural-preview-tamil {
  grid-column: 1 / -1;
  font-family: var(--font-tamil);
  font-size: 1.1rem;
}

.kural-preview-trans {
  grid-column: 1 / -1;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

/* =============================================
   Kural page
   ============================================= */

#kural-view {
  max-width: 100%;
  overflow-x: hidden;
}

.kural-header {
  margin-bottom: var(--space-xl);
}

/* --- Main display area --- */
.kural-display {
  max-width: 72ch;
  margin: 0 auto var(--space-xl);
}

/* Head: number + chapter link */
.kural-display-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.kural-num {
  font-family: var(--font-english);
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

.kural-chapter-link {
  font-family: var(--font-english);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-accent);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color var(--transition-fast);
}

.kural-chapter-link:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* --- Tamil verse --- */
.kural-verse {
  margin-bottom: var(--space-lg);
}

.kural-line1,
.kural-line2 {
  margin: 0;
  font-family: var(--font-tamil);
  font-size: min(1.35rem, 3.25vw);
  font-weight: bold;
  line-height: 1.75;
  letter-spacing: 0.01em;
}

/* --- Transliteration --- */
.kural-transliteration {
  margin-bottom: var(--space-lg);
  font-size: 0.95rem;
  color: var(--color-text-muted);
  font-style: italic;
  letter-spacing: 0.02em;
}

.kural-transliteration p {
  margin: 0.15em 0;
}

/* --- Horizontal rule dividers --- */
.kural-rule {
  border: none;
  height: 1px;
  background: var(--color-border);
  margin: var(--space-lg) 0;
}

/* --- Translation --- */
.kural-meaning {
  margin-bottom: var(--space-lg);
}

.kural-translation-text {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.8;
}

/* --- Couplet --- */
.kural-couplet {
  margin: 0 0 var(--space-lg);
  padding: var(--space-md) 0 var(--space-md) var(--space-lg);
  border-left: 3px solid var(--color-accent);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--color-text-muted);
}

/* --- Explanation --- */
.kural-explanation p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.8;
}

/* --- Section labels --- */
.kural-divider-label {
  margin: 0 0 var(--space-md);
  font-family: var(--font-english);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* --- Commentaries --- */
.kural-commentaries {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.commentary-item {
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.commentary-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.commentary-author {
  display: block;
  font-family: var(--font-tamil);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: var(--space-xs);
}

.commentary-item p {
  margin: 0;
  font-family: var(--font-tamil);
  font-size: 0.95rem;
  line-height: 1.75;
}

/* --- Navigation --- */
.kural-nav {
  max-width: 80ch;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg) 0;
}

.kural-progress {
  width: 100%;
  height: 2px;
  background: var(--color-bg-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.kural-progress-bar {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
}

.kural-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kural-prev,
.kural-next {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  background: transparent;
  color: var(--color-accent);
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-family: var(--font-english);
  font-weight: 600;
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.kural-prev:hover,
.kural-next:hover,
.kural-prev:focus,
.kural-next:focus {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.kural-prev:focus-visible,
.kural-next:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.kural-nav-arrow {
  font-size: 1.1em;
  line-height: 1;
}

.kural-prev.disabled,
.kural-next.disabled {
  color: var(--color-text-muted);
  border-color: var(--color-border);
  opacity: 0.4;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.kural-counter {
  font-family: var(--font-english);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.kural-counter-sep {
  opacity: 0.5;
  margin: 0 0.2em;
  font-weight: 400;
}

/* Shortcuts modal */
.shortcuts-modal {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: 90vw;
  width: 420px;
  box-shadow: var(--shadow-xl);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.shortcuts-modal::backdrop {
  background: rgba(26, 29, 38, 0.5);
}

html.theme-dark .shortcuts-modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

html.theme-sepia .shortcuts-modal::backdrop {
  background: rgba(61, 53, 38, 0.5);
}

.shortcuts-modal-content {
  padding: var(--space-xl);
}

.shortcuts-modal h2 {
  margin: 0 0 var(--space-lg);
  font-size: 1.25rem;
}

.shortcuts-list {
  display: grid;
  gap: var(--space-sm);
  margin: 0 0 var(--space-lg);
}

.shortcuts-list dt {
  font-weight: 600;
}

.shortcuts-list kbd {
  display: inline-block;
  padding: 3px 8px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-english);
  font-size: 0.85em;
  font-weight: 500;
}

.shortcuts-close {
  padding: var(--space-sm) var(--space-xl);
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-english);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.shortcuts-close:hover,
.shortcuts-close:focus {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
}

.shortcuts-close:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Error view */
.error-view {
  padding: var(--space-xl);
  color: #b45309;
  font-weight: 500;
}

/* ---- Responsive: 768px ---- */

@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex;
  }

  .sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: min(300px, 85vw);
    min-width: 200px;
    height: 100dvh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-lg);
    box-shadow: none;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl), 8px 0 32px rgba(0, 0, 0, 0.15);
  }

  .sidebar.is-open+.main-content::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 35;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  .site-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--space-sm);
    align-items: center;
    padding: var(--space-sm) var(--space-md);
  }

  .site-title {
    justify-self: center;
    font-size: 1.15rem;
  }

  .tamil-title {
    font-size: 1.1rem;
  }

  .english-title {
    font-size: 0.7rem;
  }

  .shortcuts-trigger {
    display: none;
  }

  .header-actions {
    gap: var(--space-xs);
  }

  .theme-toggle {
    gap: 1px;
    padding: 2px;
  }

  .theme-toggle .theme-btn {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.7rem;
    min-height: 2rem;
  }

  .main-content {
    padding: var(--space-sm) var(--space-md);
    max-width: none;
    overflow-x: hidden;
  }

  .loading-state {
    padding: var(--space-lg);
  }

  .home-hero {
    padding: var(--space-lg) 0 var(--space-md);
  }

  .hero-title {
    font-size: min(2.5rem, 10vw);
  }

  .hero-subtitle {
    font-size: 1.2rem;
  }

  .hero-tagline {
    font-size: 0.95rem;
  }

  .home-sections {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
  }

  .section-card {
    flex-direction: row;
    text-align: left;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
  }

  .section-card::before {
    width: 4px;
    height: 100%;
    right: auto;
    bottom: 0;
  }

  .section-card:hover::before,
  .section-card:focus::before {
    width: 6px;
    height: 100%;
  }

  .section-card-icon {
    font-size: 1.5rem;
    margin-bottom: 0;
  }

  .section-card-name {
    font-size: 1rem;
  }

  .section-card-count {
    margin-top: 0;
  }

  .kural-jump-form {
    flex-direction: column;
    align-items: stretch;
    display: flex;
  }

  .kural-jump-form input {
    width: 100%;
    text-align: left;
    border-radius: var(--radius-md);
  }

  .kural-jump-form button {
    width: 100%;
    border-radius: var(--radius-md);
  }

  .view-header {
    margin-bottom: var(--space-lg);
  }

  .view-header h2 {
    font-size: 1.25rem;
  }

  .view-header h2 span[lang="ta"] {
    font-size: 0.9rem;
    display: block;
    margin-top: var(--space-xs);
  }

  .breadcrumb {
    font-size: 0.8rem;
    line-height: 1.5;
    word-break: break-word;
  }

  .chapter-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-sm);
  }

  .chapter-card {
    padding: var(--space-md);
  }

  .chapter-name {
    font-size: 0.95rem;
  }

  .chapter-tamil {
    font-size: 0.85rem;
  }

  .chapter-range {
    font-size: 0.8rem;
  }

  .kural-list {
    gap: var(--space-sm);
  }

  .kural-preview {
    grid-template-columns: 2.5rem 1fr;
    gap: var(--space-sm);
    padding: var(--space-md);
    padding-left: var(--space-md);
  }

  .kural-preview::before {
    display: none;
  }

  .kural-preview:hover,
  .kural-preview:focus {
    transform: none;
  }

  .kural-preview-tamil {
    font-size: 1rem;
  }

  .kural-preview-trans {
    font-size: 0.9rem;
  }

  .kural-header {
    margin-bottom: var(--space-md);
  }

  .kural-display {
    max-width: 100%;
    margin-bottom: var(--space-lg);
  }

  .kural-num {
    font-size: 2.2rem;
  }

  .kural-chapter-link {
    font-size: 0.8rem;
  }

  .kural-display-head {
    margin-bottom: var(--space-lg);
  }

  .kural-line1,
  .kural-line2 {
    line-height: 1.7;
  }

  .kural-transliteration {
    font-size: 0.75rem;
  }

  .kural-translation-text {
    font-size: 1rem;
  }

  .kural-couplet {
    font-size: 0.9rem;
  }

  .kural-explanation p {
    font-size: 0.9rem;
  }

  .commentary-item p {
    font-size: 0.85rem;
  }

  .kural-nav {
    max-width: 100%;
  }

  .kural-nav-row {
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
  }

  .kural-counter {
    order: -1;
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    padding-bottom: var(--space-xs);
  }

  .kural-prev,
  .kural-next {
    flex: 1;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.8rem;
  }

  .error-view {
    padding: var(--space-md);
  }

  .nav-chapter {
    padding: var(--space-sm) var(--space-md);
    min-height: 2.75rem;
    display: flex;
    align-items: center;
  }

  .nav-chapter:hover,
  .nav-chapter:focus {
    padding-left: var(--space-md);
  }

  .nav-section-title {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  .shortcuts-modal {
    width: calc(100vw - var(--space-xl));
  }

  .shortcuts-modal-content {
    padding: var(--space-lg);
  }
}

/* ---- Responsive: 480px ---- */

@media (max-width: 480px) {
  html {
    font-size: 16px;
  }

  .site-header {
    padding: var(--space-xs) var(--space-sm);
  }

  .site-title {
    font-size: 1.05rem;
  }

  .theme-toggle .theme-btn {
    font-size: 0.65rem;
    padding: var(--space-xs);
    min-height: 1.75rem;
  }

  .main-content {
    padding: var(--space-sm) var(--space-md);
  }

  .chapter-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }

  .chapter-card {
    padding: var(--space-sm) var(--space-md);
  }

  .chapter-name {
    font-size: 0.9rem;
  }

  .kural-num {
    font-size: 1.8rem;
  }

  .kural-line1,
  .kural-line2 {
    line-height: 1.65;
  }

  .kural-rule {
    margin: var(--space-md) 0;
  }

  .kural-translation-text {
    font-size: 0.95rem;
  }

  .kural-couplet {
    font-size: 0.85rem;
  }

  .kural-explanation p {
    font-size: 0.85rem;
  }

  .kural-nav {
    padding: var(--space-sm) 0;
  }

  .kural-prev,
  .kural-next {
    flex: 1;
    justify-content: center;
    padding: var(--space-sm) var(--space-sm);
  }

  .view-header h2 {
    font-size: 1.15rem;
  }

  .kural-preview {
    padding: var(--space-sm) var(--space-md);
    padding-left: var(--space-md);
    gap: var(--space-xs);
  }

  .kural-preview-tamil {
    font-size: 0.95rem;
  }

  .kural-preview-trans {
    font-size: 0.85rem;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1.05rem;
  }

  .hero-tagline {
    font-size: 0.875rem;
  }

  .section-card {
    padding: var(--space-sm) var(--space-md);
  }

  .section-card-name {
    font-size: 0.9rem;
  }
}

/* ---- Animations ---- */

@keyframes kural-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(60px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes kural-slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-60px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes view-fade-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes stagger-fade-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.kural-display.enter-right {
  animation: kural-slide-in-right 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.kural-display.enter-left {
  animation: kural-slide-in-left 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.view-entering {
  animation: view-fade-in 350ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.chapter-grid .chapter-card {
  animation: stagger-fade-in 400ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.chapter-grid .chapter-card:nth-child(1) {
  animation-delay: 0ms;
}

.chapter-grid .chapter-card:nth-child(2) {
  animation-delay: 30ms;
}

.chapter-grid .chapter-card:nth-child(3) {
  animation-delay: 60ms;
}

.chapter-grid .chapter-card:nth-child(4) {
  animation-delay: 90ms;
}

.chapter-grid .chapter-card:nth-child(5) {
  animation-delay: 120ms;
}

.chapter-grid .chapter-card:nth-child(6) {
  animation-delay: 150ms;
}

.chapter-grid .chapter-card:nth-child(7) {
  animation-delay: 180ms;
}

.chapter-grid .chapter-card:nth-child(8) {
  animation-delay: 210ms;
}

.chapter-grid .chapter-card:nth-child(n+9) {
  animation-delay: 240ms;
}

.home-sections .section-card {
  animation: stagger-fade-in 450ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.home-sections .section-card:nth-child(1) {
  animation-delay: 100ms;
}

.home-sections .section-card:nth-child(2) {
  animation-delay: 200ms;
}

.home-sections .section-card:nth-child(3) {
  animation-delay: 300ms;
}

.kural-list .kural-preview {
  animation: stagger-fade-in 350ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.kural-list .kural-preview:nth-child(1) {
  animation-delay: 0ms;
}

.kural-list .kural-preview:nth-child(2) {
  animation-delay: 40ms;
}

.kural-list .kural-preview:nth-child(3) {
  animation-delay: 80ms;
}

.kural-list .kural-preview:nth-child(4) {
  animation-delay: 120ms;
}

.kural-list .kural-preview:nth-child(5) {
  animation-delay: 160ms;
}

.kural-list .kural-preview:nth-child(n+6) {
  animation-delay: 200ms;
}

@media (prefers-reduced-motion: reduce) {

  .kural-display.enter-right,
  .kural-display.enter-left,
  .view-entering,
  .chapter-grid .chapter-card,
  .home-sections .section-card,
  .kural-list .kural-preview {
    animation: none;
  }
}
