/* ==========================================================================
   Kamala Jayasinghe Library — design system
   Ink, paper and saffron. Shared by the public site and BookFinder.
   ========================================================================== */

:root {
  /* palette */
  --ink: #15120e;
  --ink-2: #1e1a15;
  --ink-3: #2b251e;
  --paper: #f5f0e6;
  --paper-2: #ebe3d4;
  --paper-3: #e2d8c5;
  --card: #fbf8f2;

  --saffron: #db9200;
  --saffron-hi: #f2b33d;
  --saffron-ink: #7d5200;
  --saffron-wash: #f6e6c2;
  --maroon: #74261a;
  --leaf: #2d6a4a;
  --leaf-wash: #dcebdd;
  --danger: #a8321f;
  --danger-wash: #f5ddd6;

  /* semantic (light surfaces) */
  --bg: var(--paper);
  --surface: var(--card);
  --surface-2: var(--paper-2);
  --text: #1c1813;
  --muted: #675d51;
  --faint: #978b7c;
  --line: rgba(28, 24, 19, .12);
  --line-strong: rgba(28, 24, 19, .22);
  --on-dark: #f5f0e6;
  --on-dark-muted: rgba(245, 240, 230, .66);
  --line-dark: rgba(245, 240, 230, .14);

  /* type */
  --f-display: "Instrument Serif", "Iowan Old Style", "Times New Roman", serif;
  --f-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --f-si: "Abhaya Libre", "Noto Serif Sinhala", "Iskoola Pota", serif;

  /* shape & motion */
  --r-xs: 6px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;
  --r-arch: 999px 999px 16px 16px;
  --shadow-1: 0 1px 2px rgba(28, 24, 19, .06), 0 0 0 1px rgba(28, 24, 19, .06);
  --shadow-2: 0 18px 40px -18px rgba(28, 24, 19, .35), 0 0 0 1px rgba(28, 24, 19, .06);
  --ease: cubic-bezier(.2, .7, .1, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);

  --wrap: 1240px;
  --gutter: clamp(16px, 4vw, 40px);
  --hdr-h: 76px;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--hdr-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 var(--f-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg, video, iframe { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4, p, figure, ul, ol, dl, dd, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
address { font-style: normal; }
::selection { background: var(--saffron-hi); color: var(--ink); }
:focus-visible { outline: 2px solid var(--saffron); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

.icon { width: 1.15em; height: 1.15em; flex: none; }

.wrap { width: 100%; max-width: calc(var(--wrap) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }

.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 {
  position: fixed; left: 16px; top: 12px; z-index: 200;
  padding: 10px 16px; border-radius: var(--r-sm);
  background: var(--saffron); color: var(--ink); font-weight: 600;
  transform: translateY(-160%); transition: transform .2s var(--ease);
}
.skip:focus { transform: none; }

/* ---------- type ---------- */
.display, .h1, .h2, .h3 { font-family: var(--f-display); font-weight: 400; letter-spacing: -.012em; }
.h1 { font-size: clamp(2.8rem, 6.4vw, 5.6rem); line-height: .96; }
.h2 { font-size: clamp(2.2rem, 4.6vw, 4rem); line-height: 1; }
.h3 { font-size: clamp(1.6rem, 2.4vw, 2.1rem); line-height: 1.08; }
.h1 em, .h2 em, .h3 em { font-style: italic; color: var(--saffron-ink); }
.lede { font-size: clamp(1.05rem, 1.4vw, 1.2rem); line-height: 1.6; color: var(--muted); max-width: 56ch; }
.mono { font-family: var(--f-mono); font-feature-settings: "zero" 1; }
.si { font-family: var(--f-si); }

.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font: 500 12px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
}
.eyebrow::before { content: ""; width: 7px; height: 7px; background: var(--saffron); border-radius: 1px; transform: rotate(45deg); }

/* section index: "01 — Programmes" */
.index {
  display: flex; align-items: center; gap: 14px;
  font: 500 12px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.index b { font-weight: 500; color: var(--saffron-ink); }
.index::after { content: ""; flex: 1; height: 1px; background: var(--line-strong); }
.on-dark .index { color: var(--on-dark-muted); }
.on-dark .index b { color: var(--saffron-hi); }
.on-dark .index::after { background: var(--line-dark); }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--ink); --btn-fg: var(--paper); --btn-bd: transparent;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px;
  border-radius: 999px; border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font: 500 15px/1 var(--f-sans); letter-spacing: -.005em; white-space: nowrap;
  transition: background-color .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease), transform .25s var(--ease);
}
.btn .icon { transition: transform .3s var(--ease); }
.btn:hover .icon:last-child { transform: translateX(3px); }
.btn:hover .icon-up { transform: translate(2px, -2px) !important; }
.btn:active { transform: translateY(1px); }
.btn:hover { --btn-bg: var(--saffron); --btn-fg: var(--ink); }
.btn--saffron { --btn-bg: var(--saffron); --btn-fg: var(--ink); }
.btn--saffron:hover { --btn-bg: var(--saffron-hi); }
.btn--ghost { --btn-bg: transparent; --btn-fg: var(--text); --btn-bd: var(--line-strong); }
.btn--ghost:hover { --btn-bg: var(--text); --btn-fg: var(--paper); --btn-bd: var(--text); }
.on-dark .btn--ghost, .btn--ghost-dark { --btn-bg: transparent; --btn-fg: var(--on-dark); --btn-bd: rgba(245, 240, 230, .28); }
.on-dark .btn--ghost:hover, .btn--ghost-dark:hover { --btn-bg: var(--paper); --btn-fg: var(--ink); --btn-bd: var(--paper); }
.btn--sm { min-height: 38px; padding: 0 16px; font-size: 14px; gap: 8px; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .55; pointer-events: none; }

.link {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 500; color: var(--text);
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  padding-bottom: 2px; transition: background-size .35s var(--ease);
}
.link:hover { background-size: 100% 1px; }
.link .icon { transition: transform .3s var(--ease); }
.link:hover .icon { transform: translateX(3px); }

/* ---------- arch frame (temple arch) ---------- */
.arch { position: relative; overflow: hidden; border-radius: var(--r-arch); background: var(--ink-3); isolation: isolate; }
.arch img { width: 100%; height: 100%; object-fit: cover; }
.arch::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1); pointer-events: none; }

/* ---------- tags & status ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  font-size: 12.5px; line-height: 1.3; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tag--line { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--muted); }

.state { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state--ok { color: var(--leaf); }
.state--warn { color: var(--saffron-ink); }

.status {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px;
  padding: 7px 14px 7px 12px; border-radius: 999px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 13.5px; color: var(--muted);
}
.status strong { font-weight: 600; color: var(--text); }
.status__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status.is-open .status__dot { background: #3fae6e; box-shadow: 0 0 0 0 rgba(63, 174, 110, .5); animation: pulse 2.4s infinite; }
.status--dark { background: rgba(245, 240, 230, .07); box-shadow: inset 0 0 0 1px var(--line-dark); color: var(--on-dark-muted); }
.status--dark strong { color: var(--on-dark); }
.status--dark .status__dot { background: rgba(245, 240, 230, .4); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(63, 174, 110, 0); } 100% { box-shadow: 0 0 0 0 rgba(63, 174, 110, 0); } }

/* ---------- opening hours ---------- */
.hours { display: grid; gap: 0; }
.hours li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.hours__day { font-weight: 500; }
.hours__day em { font-style: normal; margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--saffron); color: var(--ink); font: 500 11px/1.5 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; vertical-align: 2px; }
.hours__time { font-family: var(--f-mono); font-size: 14px; color: var(--muted); }
.hours .is-today .hours__time { color: var(--text); }
.hours__note { color: var(--muted); font-size: 14px; border-bottom: 0 !important; }

/* ---------- forms ---------- */
.field { display: grid; gap: 8px; min-width: 0; }
.field > label, .label { font-size: 13.5px; font-weight: 500; color: var(--text); }
.label .req, .field .req { color: var(--saffron-ink); margin-left: 2px; }
.hint { font-size: 12.5px; color: var(--muted); }
.hint--error { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 11px 14px;
  border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
  font-size: 15px; line-height: 1.4;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background-color .2s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--saffron); box-shadow: 0 0 0 4px rgba(219, 146, 0, .18); }
.input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(168, 50, 31, .12); }
.input[readonly] { background: var(--surface-2); }
.textarea { min-height: 96px; resize: vertical; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23675d51' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon > .input { padding-left: 42px; }

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pager__pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager__num, .pager__step, .pager__gap {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 40px; height: 40px; padding: 0 12px; border-radius: 999px;
  font: 500 14px/1 var(--f-mono); color: var(--muted);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.pager__step { font-family: var(--f-sans); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
a.pager__num:hover, a.pager__step:hover { background: var(--surface-2); color: var(--text); }
.pager__num.is-current { background: var(--ink); color: var(--paper); }
.pager__step.is-disabled { opacity: .4; }
@media (max-width: 560px) {
  .pager__step span { display: none; }
  .pager__step { padding: 0; width: 40px; }
}

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 150; right: 16px; bottom: 16px; display: grid; gap: 10px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 14px 14px 16px; border-radius: var(--r);
  background: var(--ink); color: var(--paper);
  box-shadow: 0 20px 40px -16px rgba(0, 0, 0, .5);
  animation: toast-in .45s var(--ease) both;
}
.toast > .icon { margin-top: 2px; width: 20px; height: 20px; padding: 3px; border-radius: 50%; background: #3fae6e; color: var(--ink); stroke-width: 2.4; }
.toast--error > .icon { background: #e0664f; }
.toast p { flex: 1; font-size: 14.5px; line-height: 1.45; }
.toast__close { color: rgba(245, 240, 230, .6); padding: 2px; border-radius: 6px; }
.toast__close:hover { color: var(--paper); }
.toast.is-leaving { animation: toast-out .3s var(--ease-io) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- reveal on scroll (only when JS is running) ---------- */
.js [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .9s var(--ease), transform .9s var(--ease); transition-delay: var(--d, 0s); }
.js [data-reveal].is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .js [data-reveal] { opacity: 1; transform: none; }
}
