/* ============================================================
   CIVSAR — Know What To Do
   Design Tokens & Modern Stylesheet
   Matches civsar.lk reference design
   ============================================================ */
:root {
  --ink: #171412;
  --bg: #FFFAF0;
  --panel: #FFFFFF;
  --soft: #FFF1C2;
  --backdrop: #E9E5DE;
  --line: #171412;
  --yellow: #FFC93C;
  --orange: #FF6B1A;
  --orange-dark: #E55A0D;
  --accent-text: #C2410C;
  --on-y: #171412;
  --bar: #171412;
  --bar-fg: #FFFFFF;
  --lv-y: #FFD84A;
  --lv-a: #FF8A1F;
  --lv-r: #D7261E;
  --lv-k: #171412;
  --card: #FFFFFF;
  --card-ink: #171412;
  --display: "Archivo", "Noto Sans Sinhala", "Noto Sans Tamil", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #F5EFE6;
    --bg: #14110F;
    --panel: #1F1B18;
    --soft: #2D2519;
    --backdrop: #0A0807;
    --line: #D9D2C6;
    --accent-text: #FF9A5C;
    --bar: #000000;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ink: #F5EFE6;
  --bg: #14110F;
  --panel: #1F1B18;
  --soft: #2D2519;
  --backdrop: #0A0807;
  --line: #D9D2C6;
  --accent-text: #FF9A5C;
  --bar: #000000;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--backdrop);
  color: var(--ink);
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.5;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2 { text-wrap: balance; }
p { text-wrap: pretty; }
[hidden] { display: none !important; }

.page {
  max-width: 1440px;
  margin-inline: auto;
  background: var(--bg);
  border-inline: 2px solid var(--line);
  overflow: clip;
}
.pad { padding-inline: clamp(16px, 4vw, 48px); }

.eyebrow {
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent-text);
}
html[lang="si"] .eyebrow, html[lang="ta"] .eyebrow {
  letter-spacing: .02em;
  text-transform: none;
  font-size: .95rem;
}

/* Offline Banner */
.pwa-bar {
  background: #0B4F37;
  color: #FFF;
  padding: 8px 16px;
  font-size: .85rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--line);
}
.pwa-bar button {
  background: transparent;
  border: 1px solid #FFF;
  color: #FFF;
  padding: 4px 10px;
  font-size: .78rem;
  cursor: pointer;
  border-radius: 4px;
  font-weight: 700;
}
.pwa-bar button:hover { background: rgba(255, 255, 255, 0.2); }

/* Emergency Hotline Header Bar — BLACK bar, yellow badge around 117 */
.emg {
  background: #171412;
  color: #FFFFFF;
  padding-block: 10px;
  font-weight: 600;
  font-size: .88rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid var(--line);
}
.emg b a { color: inherit; text-decoration: none; }
/* Yellow badge around emergency number */
.emg b {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.emg b a {
  background: var(--yellow);
  color: #171412;
  font-size: 1.1rem;
  font-weight: 900;
  padding: 2px 12px;
  letter-spacing: .02em;
}

/* Top Nav & Branding — white, clean */
.top {
  background: #FFFFFF;
  padding-block: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--ink);
}
.brand .nm { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; color: #171412; }
.brand .sep { width: 2px; height: 36px; background: var(--line); }

/* ---- Logo ---- */
.brand-logo {
  display: block;
  height: 36px;
  width: auto;
  object-fit: contain;
}
.about .civsar-logo-badge .brand-logo {
  height: auto;
  width: 100%;
  max-width: 360px;
}

.nav {
  display: flex;
  gap: 24px;
  font-weight: 600;
  font-size: .93rem;
  flex-wrap: wrap;
  color: #171412;
}
.nav a {
  text-decoration: none;
  color: #171412;
  transition: color .15s;
}
.nav a:hover { color: var(--orange); }
.lang {
  display: flex;
  border: 2px solid var(--line);
  background: var(--panel);
}
.lang button {
  border: 0;
  border-right: 2px solid var(--line);
  padding: 6px 13px;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  font-size: .85rem;
  color: #171412;
  transition: background .15s;
}
.lang button:last-child { border-right: 0; }
.lang button[aria-pressed="true"] {
  background: var(--yellow);
  color: #171412;
}
.lang button:hover:not([aria-pressed="true"]) { background: #f5f0e8; }

/* Hero Section */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  border-bottom: 2px solid var(--line);
  min-height: 520px;
}
.hero-l {
  background: var(--bg);
  padding-block: clamp(40px, 6vw, 72px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.hero-l h1 {
  font-size: clamp(2.8rem, 5.5vw, 4.4rem);
  line-height: 1.0;
  letter-spacing: -.035em;
  font-weight: 900;
  color: #171412;
}
html[lang="si"] .hero-l h1, html[lang="ta"] .hero-l h1 {
  letter-spacing: 0;
  line-height: 1.2;
}
.hero-l .dot { color: var(--orange); }
.hero-l .lede {
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  max-width: 38rem;
  line-height: 1.55;
  color: #171412;
}
.hero-l .lede a { color: var(--accent-text); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span {
  border: 2px solid var(--line);
  padding: 6px 14px;
  font-size: .85rem;
  font-weight: 800;
  background: #FFFFFF;
  color: #171412;
  cursor: default;
  transition: background .15s;
}
.chips span:hover { background: var(--soft); }
.ctas { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.btn {
  border: 2px solid var(--line);
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
/* Primary = ORANGE (matching the screenshot CTA) */
.btn.pri { background: var(--orange); color: #FFFFFF; border-color: var(--line); }
.btn.pri:hover { background: var(--orange-dark); }
.btn.sec { background: var(--panel); color: var(--ink); }
.btn.sec:hover { background: var(--soft); }

/* Right panel — vivid orange with decorative circles */
.hero-r {
  background: var(--orange);
  border-left: 2px solid var(--line);
  padding: clamp(24px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
/* Decorative background circles */
.hero-r::before,
.hero-r::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.hero-r::before {
  width: 320px;
  height: 320px;
  background: #E55A0D;
  top: -80px;
  right: -60px;
  opacity: .7;
}
.hero-r::after {
  width: 200px;
  height: 200px;
  background: var(--yellow);
  bottom: -60px;
  left: -40px;
  opacity: .55;
}

/* The Household Card — tilted slightly, floating */
.card {
  width: 100%;
  max-width: 390px;
  background: var(--card);
  color: var(--card-ink);
  border: 2px solid var(--line);
  box-shadow: 8px 8px 0 var(--line);
  position: relative;
  z-index: 2;
  transform: rotate(1.2deg);
  transition: transform .2s;
}
.card:hover { transform: rotate(0deg) translateY(-3px); }

/* Card header — ORANGE */
.card .hd {
  background: var(--orange);
  color: #FFFFFF;
  padding: 13px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 900;
  font-size: .95rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--line);
}
.card .hd small { font-size: .8rem; font-weight: 700; letter-spacing: 0; opacity: .9; }

.card .bd { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.card label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; font-weight: 800; }

/* Card inputs — dashed underline style (like the screenshot) */
.card input {
  border: none;
  border-bottom: 2px dashed var(--line);
  padding: 6px 2px;
  background: transparent;
  color: var(--ink);
  font-size: .92rem;
  outline: none;
  transition: border-color .15s;
}
.card input:focus { border-bottom-color: var(--orange); border-bottom-style: solid; }

.card .nums {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: #171412;
  padding: 8px;
  border-top: 2px solid var(--line);
  text-align: center;
  font-weight: 900;
}
.card .nums span {
  background: var(--yellow);
  color: #171412;
  border: 1px solid rgba(0,0,0,.2);
  padding: 5px 0;
  font-size: 1rem;
}
.card .note { font-size: .78rem; opacity: .7; }
.card .tear {
  border-top: 2px dashed var(--line);
  padding: 8px;
  text-align: center;
  font-size: .78rem;
  font-weight: 800;
  background: var(--panel);
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: unset; }
  .hero-r { border-left: 0; border-top: 2px solid var(--line); min-height: 420px; }
  .card { transform: none; max-width: 100%; }
  .card:hover { transform: none; }
}

/* Instant Search Filter */
.search-wrap {
  background: var(--panel);
  padding-block: 16px;
  border-bottom: 2px solid var(--line);
}
.search-input-box {
  width: 100%;
  border: 2px solid var(--line);
  padding: 14px 18px;
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--bg);
  color: var(--ink);
}
.search-results {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.search-card {
  border: 2px solid var(--line);
  padding: 12px;
  background: var(--soft);
  cursor: pointer;
  font-size: .9rem;
}
.search-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-text);
}

/* Sections */
.sec {
  padding-block: clamp(36px, 5vw, 64px);
  border-bottom: 2px solid var(--line);
}
.sec .head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px 32px;
  margin-bottom: 28px;
}
.sec h2 {
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -.02em;
}
html[lang="si"] .sec h2, html[lang="ta"] .sec h2 {
  letter-spacing: 0;
  line-height: 1.25;
}

/* Situation Tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.tile {
  border: 2px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  text-align: left;
  background: var(--panel);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.tile:hover {
  transform: translate(-3px, -3px);
  box-shadow: 5px 5px 0 var(--line);
}
.tile .n { font-size: .85rem; font-weight: 800; color: var(--accent-text); }
.tile .t { font-size: 1.1rem; font-weight: 800; line-height: 1.3; }
.tile .arr { align-self: flex-end; font-size: 1.3rem; font-weight: 800; }
.tile.y { background: var(--yellow); color: var(--on-y); }
.tile.o { background: var(--orange); color: #fff; }
.tile.w { background: var(--panel); }
.tile.s { background: var(--soft); }

/* Warning Decoder */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tabs button {
  border: 2px solid var(--line);
  border-bottom: 0;
  padding: 12px 18px;
  font-size: .95rem;
  font-weight: 800;
  background: var(--panel);
  cursor: pointer;
  white-space: nowrap;
}
.tabs button[aria-selected="true"] {
  background: var(--yellow);
  color: var(--on-y);
  transform: translateY(2px);
}
.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 2px solid var(--line);
  background: var(--panel);
  margin-bottom: 16px;
}
.lv {
  border-right: 2px solid var(--line);
  display: flex;
  flex-direction: column;
}
.lv:last-child { border-right: 0; }
.lv .top2 {
  padding: 14px 16px;
  border-bottom: 2px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-weight: 800;
}
.lv .bd {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: .92rem;
}
.k-y { background: var(--lv-y); color: #171412; }
.k-a { background: var(--lv-a); color: #fff; }
.k-r { background: var(--lv-r); color: #fff; }
.k-k { background: var(--lv-k); color: #fff; }
.k-s { background: #FFF1C2; color: #171412; }
.k-c { background: var(--yellow); color: #171412; }
.k-w { background: #fff; color: #171412; }
.dnote { font-size: .9rem; font-weight: 600; }
@media (max-width: 900px) {
  .levels { grid-template-columns: 1fr; }
  .lv { border-right: 0; border-bottom: 2px solid var(--line); }
  .lv:last-child { border-bottom: 0; }
}

/* Checklist (Part 3 - Before) */
.ten {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 48px;
}
.ten .l { display: flex; flex-direction: column; gap: 16px; }
.count { font-size: 2.5rem; font-weight: 800; line-height: 1; }
.count small { font-size: 1.1rem; }
.bar { height: 20px; border: 2px solid var(--line); background: var(--panel); }
.bar i { display: block; height: 100%; background: var(--orange); transition: width .25s; }
.list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 2px solid var(--line);
  border-left: 2px solid var(--line);
  align-self: start;
}
.it {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-align: left;
  padding: 16px 18px;
  border: 0;
  border-right: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  min-height: 76px;
  line-height: 1.4;
  font-size: .95rem;
}
html[lang="si"] .it, html[lang="ta"] .it { line-height: 1.6; }
.it:hover { background: var(--soft); }
.it .bx {
  flex: none;
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: var(--panel);
  color: #171412;
}
.it[aria-pressed="true"] { background: var(--soft); }
.it[aria-pressed="true"] .bx { background: var(--orange); color: #FFF; }
@media (max-width: 900px) { .ten { grid-template-columns: 1fr; gap: 28px; } }
@media (max-width: 560px) { .list { grid-template-columns: 1fr; border-left: 0; } .it { border-right: 0; padding-inline: 4px; } }

/* Go-Bag Checklist */
.gobag-sec {
  margin-top: 32px;
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 24px;
}
.gobag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.gobag-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  padding: 10px 14px;
  background: var(--bg);
  font-size: .92rem;
  font-weight: 600;
}
.gobag-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--orange); }
.gobag-add { display: flex; gap: 8px; margin-top: 16px; }
.gobag-add input { flex: 1; border: 2px solid var(--line); padding: 8px 12px; }

/* About & Numbers */
.about {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
}
.about .logo-badge {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  color: var(--ink);
  padding: 28px 24px;
  border: 2px solid var(--line);
  box-shadow: 6px 6px 0 var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.about p { font-size: 1.1rem; max-width: 36rem; }
.about .stand {
  display: inline-block;
  margin-top: 14px;
  border: 2px solid var(--line);
  padding: 8px 14px;
  font-weight: 800;
  background: var(--soft);
}
@media (max-width: 900px) { .about { grid-template-columns: 1fr; gap: 28px; } }

.numbers {
  background: var(--bar);
  color: var(--bar-fg);
  padding-block: clamp(36px, 5vw, 56px);
  display: flex;
  flex-direction: column;
  gap: 26px;
  border-bottom: 2px solid var(--line);
}
.numbers h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); letter-spacing: -.02em; font-weight: 800; }
html[lang="si"] .numbers h2, html[lang="ta"] .numbers h2 { letter-spacing: 0; line-height: 1.3; }
.ng {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 2px solid #fff;
}
.ng div { padding: 22px 20px 8px 0; display: flex; flex-direction: column; gap: 6px; }
.ng b { font-size: clamp(2.6rem, 5vw, 4rem); line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.ng span { font-size: .95rem; line-height: 1.5; }
@media (max-width: 900px) { .ng { grid-template-columns: 1fr 1fr; } }

/* Footer & References */
.foot {
  background: var(--panel);
  padding-block: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: .88rem;
}
.foot .r { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 32px; }
.foot .proto { font-size: .8rem; opacity: .8; border-top: 2px solid var(--line); padding-top: 12px; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  background: #171412;
  color: #fff;
  border: 2px solid var(--yellow);
  padding: 12px 18px;
  max-width: min(560px, calc(100% - 32px));
  font-size: .9rem;
  z-index: 200;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.cite {
  font-size: .62em;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
  vertical-align: super;
  line-height: 0;
  margin-left: .2em;
  font-style: normal;
}
.cite a {
  color: inherit;
  text-decoration: underline dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  padding: 0 .05em;
}
.cite a:hover { text-decoration-style: solid; }
.refs-sec { background: var(--panel); }
.reflist { display: flex; flex-direction: column; border-top: 2px solid var(--line); }
.ref {
  display: flex;
  gap: 14px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--line);
  font-size: .86rem;
  line-height: 1.55;
  scroll-margin-top: 90px;
}
.ref .rn { flex: none; min-width: 2.8em; font-weight: 800; font-variant-numeric: tabular-nums; }
.ref .rt { min-width: 0; overflow-wrap: anywhere; }
.ref .rt a { color: var(--accent-text); }
.ref:target { background: var(--soft); outline: 2px solid var(--orange); }

/* Slide-Over Drawer Modal */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  backdrop-filter: blur(3px);
}
.drawer {
  width: 100%;
  max-width: 680px;
  background: var(--bg);
  color: var(--ink);
  height: 100%;
  overflow-y: auto;
  border-left: 3px solid var(--line);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}
.drawer-header {
  padding: 20px 24px;
  background: var(--orange);
  color: #FFFFFF;
  border-bottom: 2px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: sticky;
  top: 0;
  z-index: 10;
}
.drawer-header h3 { font-size: 1.45rem; font-weight: 800; line-height: 1.25; }
.drawer-close {
  background: var(--line);
  color: #FFF;
  border: 0;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.drawer-close:hover { background: var(--orange-dark); }
.drawer-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 1rem;
  line-height: 1.6;
}
.drawer-body h4 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-text);
  border-bottom: 2px solid var(--line);
  padding-bottom: 6px;
  margin-top: 10px;
}
.drawer-body ul, .drawer-body ol { padding-left: 24px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.drawer-body .never-box {
  background: #FFD7D7;
  color: #900;
  border: 2px solid var(--line);
  padding: 14px 18px;
  font-weight: 700;
}
.drawer-body .call-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.drawer-body .call-btn {
  border: 2px solid var(--line);
  padding: 10px 16px;
  background: var(--yellow);
  color: var(--on-y);
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Print CSS */
@media print {
  body { background: #FFF; color: #000; }
  .pwa-bar, .emg, .top, .hero-l, .search-wrap, .sec, .numbers, .foot, .toast, .drawer-backdrop { display: none !important; }
  .page { border: 0; max-width: 100%; }
  .hero { border: 0; }
  .hero-r { background: #FFF; padding: 0; border: 0; }
  .card { box-shadow: none; border: 3px solid #000; width: 100%; max-width: 100%; transform: none; }
  .card .hd { background: #000; color: #FFF; }
  .card input { border: none; border-bottom: 1px solid #000; background: #FFF; color: #000; }
  .card .nums { background: #171412; border: 1px solid #000; }
}
