/* Sky Library Network - landing page
   Palette follows the logo: navy globe, maroon lettering, and the five-band
   spectrum of the open book (red, orange, lime, green, blue). */

:root {
  --ink: #12233f;
  --navy: #1c2c4e;
  --teal: #317d93;
  --blue: #0f4c8a;
  --wash: #eef5f9;
  --paper: #ffffff;
  --line: #d3e1ea;
  --slate: #52647c;
  --amber: #f7a125;
  --amber-soft: #fbd9a0;
  --spec-red: #e8262a;
  --spec-lime: #c8d82b;
  --spec-green: #15a050;

  --font-display: "Literata", "Noto Serif Sinhala", Georgia, serif;
  --font-ui: "Figtree", "Noto Sans Sinhala", "Iskoola Pota", system-ui, -apple-system, "Segoe UI", sans-serif;
  --wrap: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: 92px; }

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

img, svg { max-width: 100%; }
a { color: var(--blue); }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; line-height: 1.15; text-wrap: balance; }
p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.hero :focus-visible, .closing :focus-visible, .site-footer :focus-visible, .topbar :focus-visible { outline-color: #ffc46b; }
.signin :focus-visible { outline-color: var(--blue); }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border: 2px solid transparent; border-radius: 10px;
  font: 600 1rem/1.2 var(--font-ui); text-decoration: none; text-align: center;
  cursor: pointer; transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--amber); color: var(--ink); }
.btn-primary:hover { background: #ffb547; }
.btn-ghost { border-color: rgba(255, 255, 255, .6); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, .12); border-color: #fff; }
.btn-quiet { border-color: var(--line); color: var(--ink); background: var(--paper); }
.btn-quiet:hover { border-color: var(--blue); color: var(--blue); }
.btn-lg { min-height: 52px; padding: 12px 26px; font-size: 1.0625rem; }
.btn-block { width: 100%; }

/* Top bar (only rendered when contact details exist in .env) */
.topbar { background: var(--navy); color: rgba(255, 255, 255, .86); font-size: .875rem; }
.topbar-row { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 4px 24px; padding-top: 7px; padding-bottom: 7px; }
.topbar a { color: inherit; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--paper); }
.header-row { display: flex; align-items: center; gap: 24px; min-height: 76px; position: relative; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--ink); text-decoration: none; }
.brand img { flex: none; display: block; width: 52px; height: 52px; object-fit: contain; }
.brand-name {
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-nav { display: flex; align-items: center; gap: 28px; margin-left: auto; }
.site-nav a {
  color: var(--ink); text-decoration: none; font-weight: 500; padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { border-bottom-color: var(--amber); }
.header-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.nav-toggle {
  display: none; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); cursor: pointer; align-items: center; justify-content: center;
}
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
  display: block; width: 20px; height: 2px; background: var(--ink); border-radius: 2px; content: ""; position: relative;
}
.nav-toggle-bars::before { position: absolute; top: -6px; }
.nav-toggle-bars::after { position: absolute; top: 6px; }

.spectrum {
  height: 5px;
  background: linear-gradient(90deg,
    var(--spec-red) 0 20%, var(--amber) 20% 40%, var(--spec-lime) 40% 60%,
    var(--spec-green) 60% 80%, var(--blue) 80% 100%);
}

/* Hero */
.hero {
  position: relative; overflow: hidden; color: #fff;
  padding: 72px 0 40px;
  background: linear-gradient(135deg, var(--navy) 0%, #24587a 55%, var(--teal) 100%);
}
.hero > .wrap { position: relative; z-index: 1; }
.hero-island { position: absolute; right: -2%; top: -6%; height: 118%; width: auto; fill: rgba(255, 255, 255, .06); pointer-events: none; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, 420px); gap: 64px; align-items: center; }
.hero h1 { font-weight: 700; font-size: clamp(2.5rem, 5.4vw, 4.1rem); letter-spacing: -.01em; line-height: 1.04; }
.lead { margin-top: 22px; max-width: 34rem; font-size: 1.25rem; line-height: 1.55; color: rgba(255, 255, 255, .92); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 34px; }

.signin {
  background: var(--paper); color: var(--ink); border-radius: 16px; padding: 30px 28px 26px;
  box-shadow: 0 30px 60px -30px rgba(6, 14, 34, .7);
}
.signin h2 { font-size: 1.4rem; margin-bottom: 18px; }
.signin-note { margin: -8px 0 18px; color: var(--slate); }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-weight: 600; font-size: .95rem; }
.field input {
  width: 100%; height: 46px; padding: 0 14px; font: inherit; color: var(--ink);
  background: #fbfdfe; border: 1.5px solid #b9cbd8; border-radius: 8px;
}
.field input:focus { border-color: var(--blue); outline: 3px solid rgba(15, 76, 138, .25); outline-offset: 0; }
.pw { position: relative; }
.pw input { padding-right: 68px; }
.pw-toggle {
  position: absolute; right: 6px; top: 6px; height: 34px; padding: 0 12px;
  border: 0; border-radius: 6px; background: transparent; color: var(--blue);
  font: 600 .9rem var(--font-ui); cursor: pointer;
}
.pw-toggle:hover { background: var(--wash); }
.signin-links { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 18px; font-size: .95rem; }

.live { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 56px; border-top: 1px solid rgba(255, 255, 255, .22); }
.live-item { display: flex; flex-direction: column-reverse; gap: 6px; padding: 26px 24px 8px; border-left: 1px solid rgba(255, 255, 255, .22); }
.live-item:first-child { border-left: 0; padding-left: 0; }
.live dt { font-size: .98rem; color: rgba(255, 255, 255, .82); }
.live dd {
  font-family: var(--font-display); font-weight: 600; font-size: clamp(2.1rem, 4.2vw, 3.1rem);
  line-height: 1; font-variant-numeric: lining-nums tabular-nums;
}
.live-note { margin-top: 18px; font-size: .9rem; color: rgba(255, 255, 255, .75); }

/* Sections */
.section { padding: 88px 0; }
.section-head { max-width: 44rem; margin-bottom: 40px; }
.section-head h2 { font-size: clamp(1.8rem, 3.3vw, 2.6rem); }
.section-head p { margin-top: 12px; color: var(--slate); max-width: 38rem; }

/* Map */
.map-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 32px; align-items: start; }
.map-card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.map-bar { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 4px 12px; flex-wrap: wrap; }
.map-back {
  min-height: 36px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--paper);
  color: var(--ink); font: 600 .92rem var(--font-ui); cursor: pointer;
}
.map-back:hover { border-color: var(--blue); color: var(--blue); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; list-style: none; font-size: .95rem; color: var(--slate); }
.crumbs li + li::before { content: "/"; margin: 0 8px; color: #97aab9; }
.crumbs button { padding: 2px 0; border: 0; background: none; color: var(--blue); font: 600 inherit var(--font-ui); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }

.map-stage { position: relative; height: clamp(440px, 76vh, 720px); overflow: hidden; border-radius: 12px; background: #e3eff6; }
.map-stage svg { display: block; width: 100%; height: 100%; touch-action: manipulation; }
.map-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--slate); }

.island-base { fill: #f9fcfd; stroke: rgba(18, 35, 63, .28); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.region {
  stroke: rgba(18, 35, 63, .34); stroke-width: 1px; vector-effect: non-scaling-stroke; stroke-linejoin: round;
  cursor: pointer; transition: fill .12s ease;
}
.region.is-hover { fill: var(--amber-soft); stroke: var(--ink); stroke-width: 1.6px; }
.region.is-selected { fill: var(--amber); stroke: var(--ink); stroke-width: 1.6px; }
.region.is-dim { stroke: rgba(18, 35, 63, .18); }
.region.is-open { fill: transparent; stroke: none; pointer-events: none; }
.region:focus { outline: none; }
.region:focus-visible { stroke: var(--ink); stroke-width: 3px; }

.map-labels { pointer-events: none; font-family: var(--font-ui); }
.map-labels text {
  fill: var(--ink); font-weight: 600; text-anchor: middle; dominant-baseline: middle;
  paint-order: stroke; stroke: rgba(255, 255, 255, .92); stroke-width: 3px; stroke-linejoin: round;
}
.map-labels .badge { fill: var(--amber); stroke: var(--ink); stroke-width: 1.2px; vector-effect: non-scaling-stroke; }
.map-labels .badge-n { stroke: none; font-weight: 700; }

.map-tip {
  position: absolute; z-index: 3; pointer-events: none; padding: 8px 12px; border-radius: 8px;
  background: var(--ink); color: #fff; font-size: .9rem; line-height: 1.35; white-space: nowrap;
  box-shadow: 0 10px 24px -10px rgba(6, 14, 34, .6);
}
.map-tip strong { display: block; font-weight: 600; }
.map-tip span { color: #cfe0ee; }

.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 14px 4px 0; font-size: .875rem; color: var(--slate); }
.ramp { width: 120px; height: 10px; border-radius: 999px; background: linear-gradient(90deg, #cde6ee, #1e6a8a); }
.legend-none { display: inline-flex; align-items: center; gap: 8px; margin-left: 12px; }
.legend-none i { display: block; width: 16px; height: 12px; border-radius: 3px; background: #f9fcfd; border: 1px solid rgba(18, 35, 63, .34); }
.map-note { padding: 8px 4px 0; font-size: .82rem; color: var(--slate); }

.map-panel {
  position: sticky; top: 96px; max-height: calc(100vh - 120px); overflow: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 26px 24px;
}
.panel-context { color: var(--slate); font-size: .95rem; }
.panel-title { margin-top: 2px; font-size: 1.9rem; }
.panel-title:focus { outline: none; }
.mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 20px 0 6px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mini div { display: flex; flex-direction: column-reverse; gap: 2px; }
.mini dt { font-size: .875rem; color: var(--slate); }
.mini dd { font-family: var(--font-display); font-weight: 600; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.panel-sub { margin: 22px 0 6px; font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; line-height: 1.25; }
.region-list { list-style: none; }
.region-list li + li { border-top: 1px solid var(--line); }
.region-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; padding: 12px 8px; margin: 0;
  border: 0; border-radius: 8px; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.region-row:hover, .region-row.is-hover { background: var(--wash); }
.rr-name { font-weight: 600; }
.rr-meta { color: var(--slate); font-size: .92rem; font-variant-numeric: tabular-nums; }
.rr-bar { grid-column: 1 / -1; height: 5px; margin-top: 6px; border-radius: 999px; background: #e1ebf1; overflow: hidden; }
.rr-bar i { display: block; height: 100%; border-radius: 999px; background: var(--blue); }
.panel-box { margin-top: 20px; padding: 16px 18px; border-radius: 12px; background: var(--wash); }
.panel-box p + p, .panel-box p + .btn, .panel-box .btn + .btn { margin-top: 12px; }
.panel-box .btn { margin-right: 8px; }

/* How it works */
.how { background: var(--paper); }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; padding-top: 18px; border-top: 4px solid var(--blue); }
.steps li:nth-child(1) { border-top-color: var(--spec-red); }
.steps li:nth-child(2) { border-top-color: var(--amber); }
.steps li:nth-child(3) { border-top-color: var(--spec-green); }
.steps li::before {
  content: counter(step); display: block; margin-bottom: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 2.6rem; line-height: 1; color: var(--ink);
}
.steps h3 { font-size: 1.25rem; }
.steps p { margin-top: 8px; color: var(--slate); }
.how-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 44px; }

/* Numbers */
.numbers-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 64px; align-items: start; }
.ledger div { display: flex; align-items: baseline; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.ledger dt { order: 0; }
.ledger div::before { content: ""; order: 1; flex: 1; min-width: 24px; border-bottom: 2px dotted #a3b9c8; transform: translateY(-4px); }
.ledger dd { order: 2; font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.ledger dd span { font: inherit; }
.bars-block h3 { font-size: 1.2rem; margin-bottom: 14px; }
.bars-block + .bars-block { margin-top: 38px; }
.bar-list { list-style: none; }
.bar-list li { display: grid; grid-template-columns: minmax(0, 9.5rem) 1fr auto; gap: 14px; align-items: center; padding: 7px 0; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; border-radius: 999px; background: #d9e6ee; overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 999px; background: var(--blue); }
.bar-val { min-width: 2ch; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Recent books */
.shelf-section { background: var(--paper); }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 30px 24px; list-style: none; }
.book-cover {
  display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; background: #dfe9f0;
  border-radius: 3px 8px 8px 3px; border-left: 5px solid rgba(18, 35, 63, .35);
  box-shadow: 0 16px 26px -16px rgba(18, 35, 63, .65);
}
.book-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 14px; font-family: var(--font-display); font-weight: 600; font-size: 1rem; line-height: 1.3;
}
.book-author { margin-top: 4px; font-size: .92rem; color: var(--slate); }
.book-lib { margin-top: 2px; font-size: .84rem; color: var(--slate); }

/* Closing */
.closing { background: var(--navy); color: #fff; padding: 64px 0; }
.closing-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px 40px; }
.closing h2 { font-size: clamp(1.7rem, 3vw, 2.3rem); }
.closing-actions { display: flex; flex-wrap: wrap; gap: 14px; }

/* Footer */
.site-footer { background: #0e1a31; color: rgba(255, 255, 255, .78); font-size: .98rem; }
.site-footer a { color: #fff; }
.footer-grid { display: flex; flex-wrap: wrap; gap: 40px 72px; padding-top: 56px; padding-bottom: 48px; }
.footer-brand { flex: 1 1 280px; max-width: 400px; }
.site-footer .brand { color: #fff; margin-bottom: 14px; }
.site-footer .brand img { width: 44px; height: 44px; padding: 3px; border-radius: 50%; background: #fff; }
.footer-brand p { max-width: 30ch; }
.footer-col { flex: 0 1 190px; }
.footer-col h2 { margin-bottom: 14px; font-family: var(--font-ui); font-size: 1rem; font-weight: 700; color: #fff; }
.footer-col ul, .social-list { list-style: none; }
.footer-col li + li { margin-top: 9px; }
.footer-col a, .social-list a { text-decoration: none; }
.footer-col a:hover, .social-list a:hover { text-decoration: underline; }
.social-list { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 18px; }
.footer-base { border-top: 1px solid rgba(255, 255, 255, .14); }
.footer-base-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 20px; padding-bottom: 24px; font-size: .9rem; }

/* Responsive */
@media (max-width: 1000px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .signin { max-width: 460px; }
  .hero-island { right: -18%; opacity: .8; }
  .map-layout { grid-template-columns: minmax(0, 1fr); }
  .map-panel { position: static; max-height: none; }
  .numbers-grid { grid-template-columns: minmax(0, 1fr); gap: 44px; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px 28px; }
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0;
    padding: 6px 24px 14px; margin: 0; background: var(--paper); border-bottom: 1px solid var(--line);
    box-shadow: 0 20px 30px -20px rgba(6, 14, 34, .4);
  }
  .site-header.nav-open .site-nav { display: flex; }
  .site-nav a { padding: 13px 0; border-bottom: 1px solid var(--line); }
  .site-nav a:hover { border-bottom-color: var(--line); color: var(--blue); }
  .header-actions { margin-left: auto; }
}

@media (max-width: 720px) {
  .section { padding: 64px 0; }
  .hero { padding: 48px 0 28px; }
  .live { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 40px; }
  .live-item { padding: 20px 16px 8px; }
  .live-item:nth-child(odd) { border-left: 0; padding-left: 0; }
  .live-item:nth-child(n + 3) { border-top: 1px solid rgba(255, 255, 255, .22); }
  .map-stage { height: auto; aspect-ratio: 1 / 1.08; }
}

@media (max-width: 560px) {
  .wrap { padding: 0 18px; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .brand-name { font-size: .85rem; line-height: 1.15; white-space: normal; }
  .brand img { width: 44px; height: 44px; }
  .header-actions .btn { padding: 8px 14px; }
  .bar-list li { grid-template-columns: minmax(0, 7rem) 1fr auto; }
  .mini dd { font-size: 1.45rem; }
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
