/* =============================================================
   Sri Lankan Public Library — Core Styles
   Design system: "Reading Room"
   ============================================================= */

:root {
  /* ---- Color: named + purposeful ---- */
  --color-navy: #16213e;
  --color-navy-deep: #0f1730;
  --color-navy-soft: #2a3a63;
  --color-gold: #b8860b;
  --color-gold-light: #d9a441;
  --color-gold-pale: #f4e6c4;
  --color-terracotta: #b0492f;
  --color-terracotta-soft: #d97a5f;
  --color-teal: #0f6e66;
  --color-cream: #fbf7ec;
  --color-cream-deep: #f3ecd9;
  --color-paper: #fffdf8;
  --color-ink: #201d17;
  --color-ink-soft: #5b5646;
  --color-border: #e3dac2;

  /* ---- Type ---- */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-si: "Noto Sans Sinhala", var(--font-body);
  --font-ta: "Noto Sans Tamil", var(--font-body);

  /* Serif "display" pairing used for the homepage's trilingual welcome
     greeting only — one elegant, matching serif per script. */
  --font-display-si: "Noto Serif Sinhala", var(--font-display);
  --font-display-ta: "Noto Serif Tamil", var(--font-display);

  --fs-xs: 0.78rem;
  --fs-sm: 0.9rem;
  --fs-base: 1rem;
  --fs-md: 1.15rem;
  --fs-lg: 1.5rem;
  --fs-xl: 2.1rem;
  --fs-2xl: 2.9rem;
  --fs-3xl: 3.8rem;

  /* ---- Spacing scale ---- */
  --sp-1: 0.4rem;
  --sp-2: 0.8rem;
  --sp-3: 1.2rem;
  --sp-4: 1.6rem;
  --sp-5: 2.4rem;
  --sp-6: 3.6rem;
  --sp-7: 5.2rem;

  --radius-sm: 4px;
  --radius-md: 8px;

  --shadow-card:
    0 1px 2px rgba(22, 33, 62, 0.06),
    0 8px 24px -12px rgba(22, 33, 62, 0.18);

  --shadow-lift:
    0 16px 40px -16px rgba(22, 33, 62, 0.35);

  --max-width: 1180px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-ink);
  background: var(--color-cream);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

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

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-navy-deep);
  line-height: 1.15;
  margin: 0 0 var(--sp-2);
}

h1 {
  font-size: var(--fs-3xl);
  font-weight: 500;
}

h2 {
  font-size: var(--fs-2xl);
  font-weight: 500;
}

h3 {
  font-size: var(--fs-lg);
}

p {
  margin: 0 0 var(--sp-3);
}

.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}

/* ---- Visually hidden but accessible ---- */
.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;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-gold);
  color: var(--color-navy-deep);
  padding: var(--sp-2) var(--sp-3);
  z-index: 1000;
  font-weight: 600;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 0;
}

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

/* =============================================================
   Language Fonts
   ============================================================= */

[lang="si"] {
  font-family: var(--font-si) !important;
}

[lang="ta"] {
  font-family: var(--font-ta) !important;
}

/* =============================================================
   Trilingual Content Stack
   ============================================================= */

.i18n-stack {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
}

h1.i18n-stack [lang],
h2.i18n-stack [lang],
h3.i18n-stack [lang] {
  color: inherit;
  font-weight: inherit;
}

.i18n-inline {
  display: inline;
}

.i18n-inline .divider {
  color: var(--color-border);
  margin: 0 0.4em;
}

/* =============================================================
   Language Switcher
   ============================================================= */

html[data-lang="en"] .i18n-stack [lang]:not([lang="en"]),
html[data-lang="en"] .i18n-inline [lang]:not([lang="en"]) {
  display: none;
}

html[data-lang="si"] .i18n-stack [lang]:not([lang="si"]),
html[data-lang="si"] .i18n-inline [lang]:not([lang="si"]) {
  display: none;
}

html[data-lang="ta"] .i18n-stack [lang]:not([lang="ta"]),
html[data-lang="ta"] .i18n-inline [lang]:not([lang="ta"]) {
  display: none;
}

/* =============================================================
   HERO TRILINGUAL GREETING
   Sinhala → Welcome → Tamil
   ============================================================= */

.greeting {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.9rem;

  /* SAME SIZE FOR ALL THREE */
  font-size: var(--fs-2xl);

  line-height: 1.15;
  font-weight: 500;
}

/*
   Important:
   All three languages inherit exactly the same font-size.
   Their individual fonts are preserved so Sinhala/Tamil
   characters render correctly.
*/

.greeting [lang="si"],
.greeting [lang="en"],
.greeting [lang="ta"] {
  font-size: 1em !important;
  line-height: 1.15;
  font-weight: 500;
}

/* Sinhala */
.greeting [lang="si"] {
  font-family: var(--font-display-si) !important;
}

/* English */
.greeting [lang="en"] {
  font-family: var(--font-display) !important;
}

/* Tamil */
.greeting [lang="ta"] {
  font-family: var(--font-display-ta) !important;
}

/* =============================================================
   Eyebrow / Section Label
   ============================================================= */

.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: var(--fs-xs);
  color: var(--color-terracotta);
  font-weight: 600;
}

/* =============================================================
   Buttons
   ============================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: var(--fs-sm);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-gold);
  color: var(--color-navy-deep);
}

.btn-primary:hover {
  background: var(--color-gold-light);
}

.btn-secondary {
  background: transparent;
  border-color: var(--color-navy);
  color: var(--color-navy);
}

.btn-secondary:hover {
  background: var(--color-navy);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--color-navy);
  padding: 0.5rem 0.75rem;
}

.btn-ghost:hover {
  text-decoration: underline;
}

.btn-danger {
  background: #b0492f;
  color: #fff;
}

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

.btn-block {
  width: 100%;
}

/* =============================================================
   Section Wrapper
   ============================================================= */

.section {
  padding-block: var(--sp-6);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--sp-3);
}

.section-head h2 {
  margin: 0;
}

.section-link {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--color-terracotta);
  font-weight: 600;
  flex-shrink: 0;
}

.section-link:hover {
  text-decoration: underline;
}

/* =============================================================
   Page Hero
   ============================================================= */

.page-hero {
  background: var(--color-navy-deep);
  color: #fff;
  padding-block: var(--sp-6) var(--sp-5);
}

.page-hero .eyebrow {
  color: var(--color-gold-light);
}

.page-hero h1 {
  color: #fff;
}

.page-hero p {
  color: #d7d3c4;
  max-width: 60ch;
}

/* =============================================================
   Forms
   ============================================================= */

.field {
  margin-bottom: var(--sp-3);
}

.field label {
  display: block;
  font-weight: 600;
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-1);
  color: var(--color-navy-deep);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-paper);
  color: var(--color-ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--color-gold);
}

.field-hint {
  font-size: var(--fs-xs);
  color: var(--color-ink-soft);
  margin-top: 0.25rem;
}

/* =============================================================
   State Banners
   ============================================================= */

.state-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-3);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-ink-soft);
  background: var(--color-paper);
}

.state-panel.is-error {
  border-color: var(--color-terracotta-soft);
  color: var(--color-terracotta);
  background: #fbeee9;
}

.state-panel .spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-gold);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =============================================================
   Reduced Motion
   ============================================================= */

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

  .spinner {
    animation-duration: 1.6s;
  }

  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}