/* Built for budget Android phones used outdoors: big targets, high contrast, red is reserved for danger. */
:root {
  --ink: #10231d;
  --paper: #f4f6f1;
  --card: #ffffff;
  --line: #d3dbd1;
  --mute: #55655d;
  --turmeric: #f0a91b;
  --leaf: #1c7c5a;
  --danger: #c4262e;
  --amber-bg: #fff1cf;
  --amber: #8a5a00;
  --font: "Noto Sans Telugu", "Noto Sans Devanagari", "Nirmala UI", "Mangal", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 18px; line-height: 1.5;
  padding-bottom: calc(250px + env(safe-area-inset-bottom, 0px));
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--turmeric); outline-offset: 2px; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  background: var(--ink); color: #fff; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
}
.top h1 { margin: 0; font-size: 1.25rem; flex: 1 1 auto; }
.langs { display: flex; gap: 6px; }
.langs button {
  min-height: 44px; padding: 0 14px; border-radius: 22px; border: 2px solid #ffffff55; background: transparent; color: #fff; cursor: pointer;
}
.langs button[aria-pressed="true"] { background: var(--turmeric); border-color: var(--turmeric); color: var(--ink); font-weight: 700; }
.net { flex: 1 0 100%; font-size: .85rem; color: #cfe3d9; }
.net::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; background: var(--leaf); }
.net.off::before { background: var(--turmeric); }

.demo { margin: 0; padding: 6px 16px; font-size: .8rem; color: var(--amber); background: var(--amber-bg); text-align: center; }

#stage { padding: 16px; max-width: 720px; margin: 0 auto; outline: none; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 18px; }
.card h2 { margin: 0 0 8px; font-size: 1.5rem; line-height: 1.25; }
.card .body { margin: 8px 0; font-size: 1.3rem; line-height: 1.55; }
.card .hint, .card .cite, .card .heard, .card .example, .card .maybe { margin: 8px 0; font-size: .95rem; color: var(--mute); }
.card .next { margin: 12px 0 4px; font-size: 1.1rem; }
.card .heard { font-size: 1.05rem; color: var(--ink); background: #0000000d; padding: 8px 10px; border-radius: 10px; }
.card .maybe { color: var(--amber); font-weight: 600; }

.card.ok { border-left: 10px solid var(--leaf); }
.card.warn { background: #eef1ea; border-style: dashed; }
.card.ask { background: var(--amber-bg); border-color: var(--turmeric); }
.card.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.card.danger h2 { font-size: 2rem; }
.card.danger .hint, .card.danger .cite, .card.danger .maybe { color: #ffe3e0; }
.card.danger .heard { color: #fff; background: #00000030; }
.card.danger .body { font-weight: 700; font-size: 1.5rem; }

.chips { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { background: #ffffff26; border: 2px solid #ffffff80; border-radius: 999px; padding: 4px 14px; font-weight: 600; }

.rows { margin: 8px 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 1.25rem; }
.rows dt { color: var(--mute); }
.rows dd { margin: 0; font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn {
  min-height: 56px; padding: 0 20px; border-radius: 14px; border: 2px solid var(--ink); background: var(--ink); color: #fff;
  font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn.light { background: transparent; color: inherit; border-color: currentColor; }
.btn.yes { background: var(--leaf); border-color: var(--leaf); flex: 1; }
.btn.no { background: var(--danger); border-color: var(--danger); flex: 1; }
.btn.call { background: #fff; color: var(--danger); border-color: #fff; font-size: 1.2rem; flex: 1 1 100%; min-height: 64px; }

.tap { max-width: 720px; margin: 0 auto; padding: 0 16px 16px; }
.tap h3 { margin: 0 0 8px; font-size: 1.1rem; }
.chiprow { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { min-height: 52px; padding: 0 16px; border-radius: 26px; border: 2px solid var(--ink); background: #fff; font-weight: 600; cursor: pointer; }

.live { max-width: 720px; margin: 0 auto; padding: 0 16px; min-height: 1.5em; color: var(--mute); font-style: italic; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 2px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
.dock > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.mic {
  width: 100%; min-height: 92px; border-radius: 46px; border: 0; background: var(--turmeric); color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 1.35rem; font-weight: 800; cursor: pointer;
}
.mic svg { width: 40px; height: 40px; flex: none; }
.mic[data-state="listening"] { background: var(--danger); color: #fff; animation: pulse 1.2s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #c4262e88; } 100% { box-shadow: 0 0 0 26px #c4262e00; } }
.row { display: flex; gap: 10px; margin-top: 10px; }
.sec { flex: 1; min-height: 52px; border-radius: 14px; border: 2px solid var(--ink); background: transparent; font-weight: 700; cursor: pointer; }
.typed { margin-top: 8px; font-size: .9rem; color: var(--mute); }
.typed summary { cursor: pointer; min-height: 32px; }
.typed form { display: flex; gap: 8px; margin-top: 6px; }
.typed input { flex: 1; min-height: 48px; border: 2px solid var(--line); border-radius: 12px; padding: 0 12px; background: #fff; }
.typed button { min-height: 48px; padding: 0 18px; border-radius: 12px; border: 2px solid var(--ink); background: var(--ink); color: #fff; font-weight: 700; }

@media (prefers-reduced-motion: reduce) { .mic[data-state="listening"] { animation: none; } }

/* ============================ motion and moving background ============================ */
html { background: var(--paper); }
body { background: transparent; }

/* village scenes cross-fade behind everything; a veil keeps text readable */
.bg {
  position: fixed; inset: 0; z-index: -2; opacity: 0; background-size: cover; background-position: center bottom;
  transition: opacity 2.6s ease; will-change: opacity, transform;
}
.bg.on { opacity: 1; }
html[data-motion="on"] .bg.on { animation: drift 30s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1) translate3d(0, 0, 0); } to { transform: scale(1.09) translate3d(-1.2%, -1%, 0); } }
.veil { position: fixed; inset: 0; z-index: -1; pointer-events: none; transition: background 0.7s ease;
  background: linear-gradient(180deg, #f4f6f100 0%, #f4f6f1b3 48%, #f4f6f1ee 100%); }
body.alert .veil { background: linear-gradient(180deg, #c4262e33 0%, #c4262e55 45%, #f4f6f1e6 100%); }

.top { background: #10231de6; }
.demo { background: #fff1cfee; }
.motion { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 2px solid #ffffff55; background: transparent; color: #fff; cursor: pointer; transition: background .25s, color .25s; }
.motion[aria-pressed="true"] { background: #ffffff26; }
.langs button, .btn, .chip, .sec, .mic, .motion { transition: transform .15s ease, background .25s ease, color .25s ease, box-shadow .25s ease; }
.btn:active, .chip:active, .sec:active, .langs button:active { transform: scale(.96); }
.chip:hover, .btn:hover { transform: translateY(-2px); }
.net.on::before { animation: ping 2.6s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 #1c7c5a99; } 100% { box-shadow: 0 0 0 9px #1c7c5a00; } }

/* cards arrive with a rise, then their parts follow one by one */
.card { background: #ffffffef; animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; box-shadow: 0 10px 30px #10231d1f; }
.card.warn { background: #eef1eaf2; }
.card.ask { background: #fff1cff5; }
.card > * { animation: fadeUp .5s ease both; }
.card > *:nth-child(1) { animation-delay: .08s; } .card > *:nth-child(2) { animation-delay: .16s; }
.card > *:nth-child(3) { animation-delay: .24s; } .card > *:nth-child(4) { animation-delay: .32s; }
.card > *:nth-child(5) { animation-delay: .40s; } .card > *:nth-child(n+6) { animation-delay: .48s; }
@keyframes rise { from { opacity: 0; transform: translateY(22px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.chips li { animation: pop .45s cubic-bezier(.3, 1.6, .5, 1) both; }
.chips li:nth-child(2) { animation-delay: .1s; } .chips li:nth-child(3) { animation-delay: .2s; } .chips li:nth-child(n+4) { animation-delay: .3s; }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }

/* the danger card shakes once, then glows */
.card.danger { animation: rise .5s cubic-bezier(.2, .8, .2, 1) both, shake .6s .45s both, glow 1.8s ease-in-out 1.1s infinite; }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 30%, 70% { transform: translateX(6px); } 50% { transform: translateX(-6px); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 #c4262e00, 0 10px 30px #10231d33; } 50% { box-shadow: 0 0 0 16px #c4262e30, 0 10px 30px #10231d33; } }
.card.danger .call { animation: nudge 2.2s ease-in-out 1.4s infinite; }
@keyframes nudge { 0%, 100% { transform: none; } 50% { transform: scale(1.03); } }

/* AI answers are marked so they are never mistaken for the verified protocol */
.card.ai { border-left: 10px solid #3b4fb0; }
.card.ai .example { color: #3b4fb0; font-weight: 600; }

.tap { background: #ffffffe6; border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; animation: rise .4s ease both; }
.live { text-shadow: 0 0 6px #fff; }

/* the mic breathes while idle, ripples and shows a live-looking wave while listening */
.mic[data-state="idle"] { animation: breathe 3.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 #f0a91b66; } 50% { box-shadow: 0 0 0 14px #f0a91b00; transform: scale(1.012); } }
.mic .bars { display: none; align-items: center; gap: 5px; height: 40px; }
.mic .bars i { display: block; width: 7px; height: 12px; border-radius: 4px; background: currentColor; animation: wave .9s ease-in-out infinite; }
.mic .bars i:nth-child(2) { animation-delay: .12s; } .mic .bars i:nth-child(3) { animation-delay: .24s; }
.mic .bars i:nth-child(4) { animation-delay: .36s; } .mic .bars i:nth-child(5) { animation-delay: .48s; }
@keyframes wave { 0%, 100% { height: 10px; } 50% { height: 38px; } }
.mic[data-state="listening"] .bars { display: flex; }
.mic[data-state="listening"] > svg { display: none; }

/* motion off: reduced-motion phones, battery saver, or the Motion button */
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation: none !important; transition: none !important; }
html[data-motion="off"] .mic[data-state="listening"] .bars i { height: 22px; }

/* compact header, dock-aware spacing, call button at the top of the danger card */
.top { gap: 4px 10px; padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px; }
.top h1 { font-size: 1.1rem; }
.net { flex: 0 0 auto; font-size: .78rem; }
.langs { flex: 1 0 100%; align-items: center; }
.langs button, .motion { min-height: 40px; padding: 0 12px; }
.motion { margin-left: auto; }
body { padding-bottom: calc(var(--dock, 250px) + 16px + env(safe-area-inset-bottom, 0px)); }
.card .lead { margin: 10px 0 4px; }
.card .lead .call { width: 100%; }

/* icon-only motion switch (a long Telugu label used to push the page wider than the phone) */
.motion { width: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.langs button { padding: 0 12px; white-space: nowrap; }
html, body { overflow-x: hidden; }

/* symptom tap list is a bottom sheet above the dock, so it is always fully reachable */
.tap { position: fixed; left: 0; right: 0; bottom: var(--dock, 220px); z-index: 5; max-width: none; margin: 0; padding: 12px 16px 14px;
  max-height: 52dvh; overflow-y: auto; background: #fffffff2; border-radius: 20px 20px 0 0; box-shadow: 0 -10px 28px #10231d38;
  animation: sheet .35s cubic-bezier(.2, .8, .2, 1) both; }
.tap > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.taphead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.tap h3 { margin: 0; }
.tapclose { width: 44px; height: 44px; border-radius: 22px; border: 2px solid var(--ink); background: transparent; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.chip { min-height: 46px; padding: 0 14px; font-size: .95rem; }
.chiprow { gap: 8px; }
@keyframes sheet { from { transform: translateY(44px); opacity: 0; } to { transform: none; opacity: 1; } }
