/* Florida Scoresheet — styles */
:root {
  --ink: #0b2545;
  --ink-2: #13315c;
  --navy: #134074;
  --accent: #1f6feb;
  --accent-d: #1a5fd0;
  --gold: #b8860b;
  --bg: #eef2f6;
  --card: #ffffff;
  --line: #d8e0e9;
  --muted: #5b6b7d;
  --text: #18222e;
  --green: #1a7f47;
  --green-bg: #e8f6ee;
  --amber: #9a5b00;
  --amber-bg: #fdf3e3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11,37,69,.06), 0 6px 20px rgba(11,37,69,.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
}

/* ---- Header ---- */
.site-header {
  background: linear-gradient(135deg, var(--ink) 0%, var(--navy) 100%);
  color: #fff;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.site-header .hwrap { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand .mark {
  width: 42px; height: 42px; border-radius: 9px; flex: none;
  background: #fff; color: var(--ink);
  display: grid; place-items: center; font-weight: 800; font-size: 19px;
  font-family: Georgia, "Times New Roman", serif; letter-spacing: -1px;
  box-shadow: inset 0 0 0 2px var(--gold);
}
.brand h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.brand .tag { margin: 1px 0 0; font-size: 12.5px; color: #c5d6ec; }
.header-spacer { flex: 1; }
.header-links a { color: #d7e6fb; font-size: 13px; text-decoration: none; margin-left: 16px; }
.header-links a:hover { color: #fff; text-decoration: underline; }

/* ---- Layout ---- */
.app-shell { max-width: 1180px; margin: 22px auto; padding: 0 20px 60px; display: grid; grid-template-columns: 1fr 360px; gap: 22px; align-items: start; }
@media (max-width: 920px) { .app-shell { grid-template-columns: 1fr; } }

.intro-note {
  grid-column: 1 / -1;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gold);
  border-radius: 10px; padding: 12px 16px; font-size: 13.5px; color: var(--muted);
}
.intro-note strong { color: var(--ink); }

/* ---- Cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: visible; }
.card > h2 {
  font-size: 15px; margin: 0; padding: 13px 18px; border-bottom: 1px solid var(--line);
  color: var(--ink); display: flex; align-items: center; gap: 10px; background: #f7fafd; border-radius: var(--radius) var(--radius) 0 0;
}
.card > h2 .sec-num {
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 700;
  min-width: 24px; height: 24px; border-radius: 6px; display: inline-grid; place-items: center; padding: 0 5px;
}
.card > h2 .sec-pts { margin-left: auto; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.card > h2 .sec-pts b { color: var(--accent); font-size: 14px; }
.card .body { padding: 16px 18px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }

/* ---- Form fields ---- */
.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.f input[type=text], .f input[type=number], .f input[type=date], .f select, select.a-qual {
  font: inherit; font-weight: 400; color: var(--text);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%;
}
.f input:focus, .f select:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.f-pts output, output.a-pts, output.p-pts {
  font-weight: 700; color: var(--accent); font-size: 15px; padding-top: 6px;
}
.scored-pill { font-size: 12px; color: var(--muted); }
.scored-pill b { color: var(--ink); }

/* checkbox rows */
.chk { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: var(--text); font-weight: 500; cursor: pointer; padding: 6px 0; }
.chk input { margin-top: 2px; width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.chk small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }

/* ---- Entry rows (additional / prior) ---- */
.ent-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; background: #fbfdff; position: relative; }
.ent-grid { display: grid; gap: 10px; align-items: end; grid-template-columns: 2fr 1.3fr 1.1fr 1.1fr .8fr .7fr auto; }
.prior-row .ent-grid { grid-template-columns: 2fr 1.3fr 1.2fr .9fr .8fr auto; }
@media (max-width: 760px) { .ent-grid, .prior-row .ent-grid { grid-template-columns: 1fr 1fr; } .ent-grid .f-search { grid-column: 1 / -1; } }
.f-desc { margin-top: 10px; }
.row-del {
  border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 8px;
  width: 34px; height: 36px; cursor: pointer; font-size: 14px; line-height: 1;
}
.row-del:hover { background: #fde8e8; color: #b42323; border-color: #f0b9b9; }
.add-btn {
  border: 1px dashed var(--accent); color: var(--accent); background: #f3f8ff; font: inherit; font-weight: 600;
  padding: 9px 14px; border-radius: 9px; cursor: pointer; font-size: 13.5px;
}
.add-btn:hover { background: #e6f0ff; }

/* ---- Autocomplete ---- */
.f-search { position: relative; }
.ac-box {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 40; margin-top: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow);
  max-height: 280px; overflow-y: auto;
}
.ac-item { display: grid; grid-template-columns: auto auto; gap: 2px 10px; padding: 8px 11px; cursor: pointer; border-bottom: 1px solid #eef2f6; }
.ac-item:hover { background: #f0f6ff; }
.ac-stat { font-weight: 700; color: var(--ink); font-size: 13px; }
.ac-lvl { font-size: 11.5px; color: #fff; background: var(--navy); border-radius: 5px; padding: 1px 7px; justify-self: end; font-weight: 600; }
.ac-desc { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* ---- Victim injury grid ---- */
.vi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
@media (max-width: 620px) { .vi-grid { grid-template-columns: 1fr; } }
.vi-item { display: grid; grid-template-columns: 1fr 78px; gap: 10px; align-items: center; border-bottom: 1px solid #eef2f6; padding: 6px 0; }
.vi-item label { font-size: 13px; color: var(--text); font-weight: 500; }
.vi-item .vi-val { font-size: 11.5px; color: var(--muted); }
.vi-item input { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

/* radios */
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.radio-row input { width: 16px; height: 16px; accent-color: var(--accent); }

/* community sanction grid */
.cs-grid { display: grid; grid-template-columns: 1fr 70px; gap: 8px 12px; align-items: center; }
.cs-grid > span, .cs-grid > label { font-size: 13px; }
.cs-grid input { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.cs-grid .cs-x { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---- Results panel ---- */
.results { position: sticky; top: 16px; }
.results .card { margin-bottom: 16px; }
.score-list { list-style: none; margin: 0; padding: 0; }
.score-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed #e6edf4; font-size: 13px; color: var(--muted); }
.score-list li span:last-child { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.score-list li.sub { border-top: 2px solid var(--line); border-bottom: none; margin-top: 4px; padding-top: 9px; color: var(--ink); font-weight: 600; }
.score-list li.sub span:last-child { color: var(--ink); }
.score-list li.enh span:last-child { color: var(--gold); }
.total-box { background: var(--ink); color: #fff; border-radius: 10px; padding: 14px 16px; margin-top: 12px; display: flex; justify-content: space-between; align-items: baseline; }
.total-box .lbl { font-size: 12.5px; letter-spacing: .4px; text-transform: uppercase; color: #b9cce6; }
.total-box .val { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }

.lps-box { border-radius: 10px; padding: 16px; margin-top: 4px; border: 1px solid var(--line); }
.lps-box .lps-cap { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; color: var(--muted); margin: 0 0 6px; }
.lps-box .lps-head { font-size: 23px; font-weight: 800; margin: 0 0 8px; line-height: 1.15; }
.lps-box .lps-det { font-size: 12.5px; color: var(--muted); margin: 0; }
.lps-none { background: var(--green-bg); border-color: #bfe6cf; }
.lps-none .lps-head { color: var(--green); }
.lps-prison { background: var(--amber-bg); border-color: #f0d9a8; }
.lps-prison .lps-head { color: var(--amber); }

.actions { display: flex; gap: 10px; margin-top: 14px; }
.btn { flex: 1; font: inherit; font-weight: 600; font-size: 14px; padding: 11px 12px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-d); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #f1f5fa; }

/* ---- Footer ---- */
.site-footer { max-width: 1180px; margin: 0 auto; padding: 22px 20px 50px; color: var(--muted); font-size: 12.5px; }
.site-footer a { color: var(--navy); }
.site-footer .disc { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }

/* ---- Disclaimer modal ---- */
.modal { position: fixed; inset: 0; background: rgba(8,20,35,.55); display: none; place-items: center; z-index: 100; padding: 20px; }
.modal.open { display: grid; }
.modal .box { background: #fff; border-radius: 12px; max-width: 560px; padding: 24px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 10px; color: var(--ink); }
.modal p { font-size: 13.5px; color: var(--text); }
.modal .close { margin-top: 12px; }

/* ---- Print view (hidden on screen) ---- */
#printView { display: none; }

/* ============================================================
   PWA / mobile (iOS-focused) enhancements
   ============================================================ */

/* Feel: never block pinch-zoom (accessibility); tame the tap flash; no sideways scroll. */
html { text-size-adjust: 100%; }
body, button, input, select, textarea { -webkit-tap-highlight-color: rgba(31, 111, 235, .18); }
html, body { overflow-x: hidden; max-width: 100%; }
img, svg { max-width: 100%; height: auto; }

/* Visible keyboard focus for every button (WCAG 2.4.7) — inputs already have it. */
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mobile-summary:focus-visible { outline: 2px solid #cdddf2; outline-offset: -3px; }

/* Safe-area insets — the black-translucent status bar lets content sit under the
   notch / home indicator, so pad the header, page gutters, and footer. */
.site-header {
  padding: calc(18px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) 18px calc(20px + env(safe-area-inset-left));
}
.app-shell { padding-left: calc(20px + env(safe-area-inset-left)); padding-right: calc(20px + env(safe-area-inset-right)); }
.site-footer { padding-left: calc(20px + env(safe-area-inset-left)); padding-right: calc(20px + env(safe-area-inset-right)); padding-bottom: calc(50px + env(safe-area-inset-bottom)); }

/* iOS auto-zooms a focused control whose font-size < 16px. Force >= 16px on phones. */
@media (max-width: 768px) {
  .f input[type=text], .f input[type=number], .f input[type=date],
  .f select, select.a-qual, .vi-item input, .cs-grid input,
  input, select, textarea { font-size: 16px; }
}

/* Touch targets >= 44x44. */
@media (pointer: coarse), (max-width: 768px) {
  .row-del { width: 44px; height: 44px; font-size: 16px; }
  .add-btn { min-height: 44px; padding: 12px 16px; }
  .btn { min-height: 48px; }
  .chk { padding: 12px 0; min-height: 44px; }
  .chk input { width: 24px; height: 24px; }
  .radio-row { gap: 12px 22px; }
  .radio-row label { min-height: 44px; }
  .radio-row input { width: 22px; height: 22px; }
  .header-links a { display: inline-block; padding: 8px 0; }
}

/* Offense autocomplete: comfortable, momentum-scrolling touch rows. */
.ac-box { -webkit-overflow-scrolling: touch; }
@media (pointer: coarse), (max-width: 768px) {
  .ac-box { max-height: 60vh; }
  .ac-item { padding: 13px 14px; min-height: 44px; align-content: center; }
}

/* ---- Sticky bottom summary bar (phones only) ---- */
.mobile-summary { display: none; }
@media (max-width: 920px) {
  .mobile-summary {
    display: flex; align-items: center; gap: 14px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    width: 100%; border: none; text-align: left; cursor: pointer; font: inherit;
    background: linear-gradient(135deg, var(--ink) 0%, var(--navy) 100%); color: #fff;
    padding: 9px calc(16px + env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
    box-shadow: 0 -2px 14px rgba(11, 37, 69, .30);
  }
  .mobile-summary .ms-block { display: flex; flex-direction: column; line-height: 1.18; }
  .mobile-summary .ms-block-lps { flex: 1; min-width: 0; }
  .mobile-summary .ms-cap { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: #b9cce6; font-weight: 600; }
  .mobile-summary .ms-total { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
  .mobile-summary .ms-lps { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-summary .ms-chevron { flex: none; font-size: 15px; color: #cdddf2; }
  /* Keep the last form fields AND the footer clear of the fixed summary bar. */
  .app-shell { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .site-footer { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }
}

/* ---- iOS "Add to Home Screen" hint ---- */
.install-hint { display: none; }
.install-hint.show {
  display: flex; align-items: center; gap: 10px;
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 95;
  background: #fff; color: var(--text);
  border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 12px;
  padding: 12px 14px; box-shadow: 0 8px 28px rgba(11, 37, 69, .24); font-size: 13.5px;
}
.install-hint .ih-icon { flex: none; color: var(--accent); display: grid; place-items: center; }
.install-hint .ih-text { margin: 0; line-height: 1.35; }
.install-hint .ih-text b { color: var(--ink); }
.install-hint .ih-close {
  flex: none; margin-left: auto; width: 44px; height: 44px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 9px; cursor: pointer; font-size: 15px; line-height: 1;
}
.install-hint .ih-close:hover { background: #f1f5fa; }
/* Lift the hint above the sticky summary bar when both are visible. */
@media (max-width: 920px) {
  .install-hint.show { bottom: calc(86px + env(safe-area-inset-bottom)); }
}

@media print {
  body { background: #fff; font-size: 11pt; }
  .site-header, .app-shell, .site-footer, .modal, .mobile-summary, .install-hint { display: none !important; }
  #printView { display: block; max-width: 7.2in; margin: 0 auto; color: #000; }
  #printView .pv-head h1 { font-size: 16pt; margin: 0 0 2px; }
  #printView .pv-sourced { font-size: 8.5pt; color: #444; margin: 0 0 12px; }
  #printView h3 { font-size: 11.5pt; margin: 14px 0 4px; border-bottom: 1px solid #000; padding-bottom: 2px; }
  #printView table { width: 100%; border-collapse: collapse; }
  #printView .pv-info th { text-align: left; font-size: 9pt; color: #333; width: 16%; padding: 3px 6px; vertical-align: top; }
  #printView .pv-info td { font-size: 10pt; padding: 3px 6px; border-bottom: 1px solid #ddd; }
  #printView .pv-table td { padding: 4px 6px; border-bottom: 1px solid #ddd; font-size: 10pt; }
  #printView .pv-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; width: 90px; }
  #printView .pv-sub td { font-weight: 700; border-top: 1.5px solid #000; }
  #printView .pv-total td { font-weight: 800; font-size: 11.5pt; border-top: 2px solid #000; }
  #printView .pv-list { margin: 4px 0; padding-left: 18px; font-size: 10pt; }
  #printView .pv-line { font-size: 10pt; margin: 3px 0; }
  #printView .pv-lps { margin-top: 12px; border: 1.5px solid #000; padding: 8px 10px; }
  #printView .pv-lps-head { font-size: 13pt; font-weight: 800; margin: 2px 0; }
  #printView .pv-disclaimer { margin-top: 16px; font-size: 8pt; color: #333; border-top: 1px solid #999; padding-top: 6px; }
}
