/* NJ MVC concept — HIG tokens (trimmed from the starter) plus the NJ MVC
   brand tokens, modernized: the government navy's kept as the brand tint,
   everything else follows the iOS semantic system. */

:root {
  color-scheme: light dark;

  --bg: #f2f2f7;
  --bg-cell: #ffffff;
  --label: #000000;
  --label-2: #6c6c70;
  --label-3: #8e8e93;
  --separator: rgb(60 60 67 / 0.29);
  --fill: rgb(120 120 128 / 0.2);
  --fill-3: rgb(118 118 128 / 0.12);
  --fill-selected: #e5e5ea;
  --backdrop: rgb(0 0 0 / 0.2);

  --tint: #007aff;
  --tint-text: #0062cc;
  --green: #34c759;
  --green-text: #1e7b34;
  --orange: #ff9500;
  --orange-text: #c93400;
  --red: #ff3b30;
  --red-text: #d70015;

  /* NJ MVC brand, modernized */
  --brand: #0056b3;          /* the portal's own accent; white text passes 7:1 */
  --brand-text: #0056b3;
  --brand-deep: #00426b;     /* the portal's navy header */
  --brand-leaf: #7a9e2f;     /* the NJMVC mark's green, for the logo only */
  --official-bg: #0b2e4f;
  --official-fg: #ffffff;

  --bar-material: rgb(242 242 247 / 0.72);

  --radius-group: 12px;
  --radius-sheet: 16px;
  --inset: 16px;
  --row-min: 44px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);

  --t-large: 2rem;
  --t-title2: 1.294rem;
  --t-title3: 1.176rem;
  --t-body: 1rem;
  --t-subhead: 0.882rem;
  --t-footnote: 0.765rem;
  --t-caption: 0.706rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-cell: #1c1c1e;
    --label: #ffffff;
    --label-2: #aeaeb2;
    --label-3: #8e8e93;
    --separator: rgb(84 84 88 / 0.65);
    --fill: rgb(120 120 128 / 0.36);
    --fill-3: rgb(118 118 128 / 0.24);
    --fill-selected: #3a3a3c;
    --backdrop: rgb(0 0 0 / 0.48);
    --tint: #0a84ff;
    --tint-text: #409cff;
    --green: #30d158;
    --green-text: #30d158;
    --orange: #ff9f0a;
    --orange-text: #ff9f0a;
    --red: #ff453a;
    --red-text: #ff6961;
    --brand-text: #7db3f5;
    --bar-material: rgb(20 20 22 / 0.72);
  }
}

@media (prefers-contrast: more) {
  :root {
    --label-2: #3a3a3c;
    --separator: rgb(0 0 0 / 0.6);
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root { --bar-material: var(--bg-cell); }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  font: -apple-system-body;
}

@supports not (font: -apple-system-body) {
  html { font-size: 17px; }
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--label);
  line-height: 1.29;
  letter-spacing: -0.024em;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-cell);
  color: var(--label);
  font-weight: 600;
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

:focus-visible {
  outline: 3px solid var(--tint);
  outline-offset: 3px;
}

/* The concept banner: honest about what this is. */
.demo-banner {
  background: color-mix(in srgb, var(--orange) 16%, var(--bg));
  color: var(--label);
  font-size: var(--t-footnote);
  text-align: center;
  padding: 6px var(--inset);
  padding-top: calc(6px + env(safe-area-inset-top));
  z-index: 60;
  position: relative;
}

/* Official lineage, slimmed: the portal's dark header becomes one line. */
.official-strip {
  background: var(--official-bg);
  color: var(--official-fg);
  font-size: var(--t-caption);
  letter-spacing: 0.02em;
  padding: 8px var(--inset);
  display: flex;
  align-items: center;
  gap: 8px;
}
.official-strip svg { flex: none; }

/* Navigation bar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--row-min);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 8px;
  background: transparent;
  border-bottom: 0.5px solid transparent;
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.navbar.is-scrolled {
  background: var(--bar-material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom-color: var(--separator);
}
.navbar-title {
  font-size: var(--t-body);
  font-weight: 600;
  margin: 0;
  opacity: 0;
  transition: opacity 0.2s;
  text-align: center;
}
.navbar.is-scrolled .navbar-title { opacity: 1; }
.navbar-leading { justify-self: start; }
.navbar-trailing { justify-self: end; }

.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: var(--row-min);
  min-width: var(--row-min);
  padding: 0 8px;
  background: none;
  border: 0;
  color: var(--brand-text);
  font-size: var(--t-body);
  cursor: pointer;
}
.nav-back [aria-hidden="true"] {
  font-size: 1.6rem;
  line-height: 1;
  font-weight: 400;
}

/* Main */
main {
  flex: 1;
  outline: none;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
main:focus-visible { outline: none; }
.tabbar-visible main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

.page-head {
  padding: 8px var(--inset) 4px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-head h1 {
  font-size: var(--t-large);
  font-weight: 700;
  letter-spacing: 0.011em;
  margin: 0;
  flex: 1;
}
.brand-mark { flex: none; }

.page-sub {
  padding: 0 var(--inset) 8px;
  color: var(--label-2);
  font-size: var(--t-subhead);
  margin: 0;
}

/* Inset grouped sections */
.section { margin: 20px 0 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 calc(var(--inset) + 4px) 6px;
  margin: 0;
  font-size: var(--t-title3);
  font-weight: 600;
}
.section-head .count { color: var(--label-2); font-weight: 400; font-size: var(--t-subhead); }

ul.list {
  list-style: none;
  margin: 0 var(--inset);
  padding: 0;
  background: var(--bg-cell);
  border-radius: var(--radius-group);
  overflow: hidden;
}
ul.list > li + li { border-top: 0.5px solid var(--separator); }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--row-min);
  padding: 10px 12px 10px 16px;
  color: var(--label);
  text-decoration: none;
  width: 100%;
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
a.row, button.row { cursor: pointer; }
.row-body { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 400; font-size: var(--t-body); }
.row-title strong { font-weight: 600; }
.row-sub {
  display: block;
  color: var(--label-2);
  font-size: var(--t-subhead);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-value {
  color: var(--label-2);
  font-size: var(--t-body);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chevron { color: var(--label-3); flex: none; font-size: 1.2rem; line-height: 1; }
.check { color: var(--brand); flex: none; }
.row[aria-disabled="true"] { opacity: 0.45; }
.row[aria-disabled="true"] .row-title { cursor: not-allowed; }

.section-foot {
  margin: 6px 0 0;
  padding: 0 calc(var(--inset) + 4px);
  color: var(--label-2);
  font-size: var(--t-footnote);
}

/* Key-value rows */
.kv { display: flex; justify-content: space-between; gap: 12px; }
.kv .k { color: var(--label-2); }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; }

/* Status card on the service detail */
.status-card {
  margin: 12px var(--inset) 0;
  background: var(--bg-cell);
  border-radius: var(--radius-group);
  padding: 14px 16px;
}
.status-card .soonest {
  font-size: var(--t-title3);
  font-weight: 600;
  color: var(--brand-text);
  font-variant-numeric: tabular-nums;
}
.status-card .soonest.none { color: var(--label-2); font-weight: 400; }
.status-card p { margin: 4px 0 0; color: var(--label-2); font-size: var(--t-subhead); }

/* Primary action block */
.action-block { margin: 16px var(--inset) 0; }

.btn-fill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: var(--t-body);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-fill:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-fill svg { flex: none; }

.btn-text {
  background: none;
  border: 0;
  color: var(--brand-text);
  font-size: var(--t-body);
  min-height: var(--row-min);
  padding: 0 12px;
  cursor: pointer;
}
.btn-destructive {
  background: none;
  border: 0;
  color: var(--red-text);
  font-size: var(--t-body);
  font-weight: 600;
  min-height: var(--row-min);
  padding: 0 12px;
  cursor: pointer;
}

/* The signature element: the visit ticket, Wallet-pass style. */
.ticket {
  display: block;
  margin: 12px var(--inset) 0;
  border-radius: 18px;
  background: linear-gradient(165deg, #0d3a61 0%, var(--brand-deep) 60%, #072a49 100%);
  color: #fff;
  text-decoration: none;
  overflow: hidden;
  box-shadow: 0 8px 24px rgb(0 40 80 / 0.25);
}
.ticket-top { padding: 16px 18px 12px; }
.ticket-service {
  font-size: var(--t-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  margin: 0 0 4px;
}
.ticket-when { font-size: var(--t-title2); font-weight: 700; margin: 0; letter-spacing: 0.01em; }
.ticket-agency { font-size: var(--t-subhead); opacity: 0.85; margin: 4px 0 0; }
.ticket-count { font-size: var(--t-title3); font-weight: 600; margin: 10px 0 0; color: #bfe0ff; }
.ticket-perf {
  border-top: 2px dashed rgb(255 255 255 / 0.35);
  margin: 0 12px;
  position: relative;
}
.ticket-perf::before, .ticket-perf::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg);
}
.ticket-perf::before { left: -21px; }
.ticket-perf::after { right: -21px; }
.ticket-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 16px;
}
.ticket-code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  font-weight: 600;
}
.ticket-cta { font-size: var(--t-subhead); opacity: 0.8; }

/* Ticket detail: the ticket large, then actions */
.ticket-detail .ticket { margin-top: 4px; }

/* Notices */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 12px var(--inset) 0;
  padding: 12px 14px;
  background: var(--bg-cell);
  border-radius: var(--radius-group);
}
.notice svg { color: var(--orange-text); flex: none; margin-top: 2px; }
.notice .n-title { font-weight: 600; margin: 0; }
.notice .n-detail { color: var(--label-2); font-size: var(--t-subhead); margin: 2px 0 0; }
.notice .btn-text { padding: 4px 0; min-height: 32px; }

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 32px;
  color: var(--label-2);
}
.empty svg { color: var(--label-3); margin-bottom: 12px; }
.empty h2 { font-size: var(--t-title2); color: var(--label); margin: 0 0 6px; }
.empty p { margin: 0; font-size: var(--t-body); }

/* Loading */
.loading { text-align: center; padding: 72px 32px; color: var(--label-2); }
.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  position: relative;
  margin-bottom: 12px;
}
.spinner i {
  position: absolute;
  left: 13px;
  top: 0;
  width: 2px;
  height: 8px;
  border-radius: 1px;
  background: var(--label-2);
  transform-origin: 1px 14px;
  opacity: 0.25;
  animation: spin-fade 1s linear infinite;
}
.spinner i:nth-child(1) { transform: rotate(0deg); animation-delay: 0s; }
.spinner i:nth-child(2) { transform: rotate(45deg); animation-delay: -0.875s; }
.spinner i:nth-child(3) { transform: rotate(90deg); animation-delay: -0.75s; }
.spinner i:nth-child(4) { transform: rotate(135deg); animation-delay: -0.625s; }
.spinner i:nth-child(5) { transform: rotate(180deg); animation-delay: -0.5s; }
.spinner i:nth-child(6) { transform: rotate(225deg); animation-delay: -0.375s; }
.spinner i:nth-child(7) { transform: rotate(270deg); animation-delay: -0.25s; }
.spinner i:nth-child(8) { transform: rotate(315deg); animation-delay: -0.125s; }
@keyframes spin-fade { to { opacity: 1; } }

/* Tab bar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  background: var(--bar-material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar[hidden] { display: none; }
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 6px;
  min-height: 52px;
  color: var(--label-2);
  text-decoration: none;
  font-size: var(--t-caption);
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--brand-text); }

/* Sheets */
dialog.sheet {
  border: 0;
  padding: 0;
  background: var(--bg-cell);
  color: var(--label);
  border-radius: var(--radius-sheet);
  width: min(560px, calc(100vw - 32px));
  max-height: min(85dvh, 720px);
}
dialog.sheet::backdrop { background: var(--backdrop); }
.sheet-grabber {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--fill);
  margin: 8px auto 0;
}
.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 0.5px solid var(--separator);
  position: sticky;
  top: 0;
  background: var(--bg-cell);
  z-index: 2;
}
.sheet-title { margin: 0; font-size: var(--t-body); font-weight: 600; text-align: center; }
.sheet-cancel { justify-self: start; }
.sheet-head-spacer { justify-self: end; min-width: 60px; }
.sheet-body { padding: 12px var(--inset) calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; }
.sheet-body .list { margin: 0; }

@media (max-width: 767px) {
  dialog.sheet {
    margin: auto auto 0;
    width: 100vw;
    max-width: 100vw;
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    max-height: 92dvh;
  }
}
@media (min-width: 768px) {
  dialog.sheet { margin: auto; }
  .sheet-grabber { display: none; }
}

/* Confirm dialog */
dialog.confirm {
  border: 0;
  border-radius: 14px;
  background: var(--bg-cell);
  color: var(--label);
  padding: 20px;
  width: min(320px, calc(100vw - 64px));
  text-align: center;
}
dialog.confirm::backdrop { background: var(--backdrop); }
dialog.confirm h2 { font-size: var(--t-body); font-weight: 600; margin: 0 0 6px; }
dialog.confirm p { font-size: var(--t-subhead); color: var(--label-2); margin: 0 0 12px; }
.confirm-actions { display: flex; justify-content: center; gap: 8px; }

/* Day picker + time grid (booking sheet) */
.day-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  -webkit-overflow-scrolling: touch;
}
.day-chip {
  flex: none;
  width: 64px;
  padding: 10px 0 8px;
  border: 0.5px solid var(--separator);
  border-radius: 12px;
  background: var(--bg-cell);
  color: var(--label);
  cursor: pointer;
  text-align: center;
}
.day-chip .dow { display: block; font-size: var(--t-caption); color: var(--label-2); }
.day-chip .dom { display: block; font-size: var(--t-title3); font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.day-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.day-chip[aria-pressed="true"] .dow { color: rgb(255 255 255 / 0.8); }
.day-chip:disabled { opacity: 0.35; cursor: not-allowed; }

.time-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.time-chip {
  min-height: var(--row-min);
  border: 0.5px solid var(--separator);
  border-radius: 10px;
  background: var(--bg-cell);
  color: var(--label);
  font-size: var(--t-body);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.time-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* Attestation toggles */
.attest {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
}
.attest + .attest { border-top: 0.5px solid var(--separator); }
.attest input {
  width: 24px;
  height: 24px;
  flex: none;
  margin-top: 2px;
  accent-color: var(--brand);
}
.attest label { font-size: var(--t-subhead); }

/* Footer */
.page-foot {
  margin: 28px 0 0;
  padding: 0 calc(var(--inset) + 4px);
  color: var(--label-2);
  font-size: var(--t-footnote);
}
.page-foot a { color: var(--brand-text); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.noscript { padding: 24px; text-align: center; }

/* Split view at regular width */
@media (min-width: 768px) {
  .split { display: grid; grid-template-columns: 340px 1fr; gap: 0; align-items: start; max-width: 1100px; margin: 0 auto; }
  .split .pane-list { border-right: 0.5px solid var(--separator); min-height: 60dvh; }
  .nav-back { display: none; }
}

/* Motion */
[hidden] { display: none !important; }@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .spinner i { animation: none; opacity: 0.6; }
}
dialog.sheet { transition: transform 0.3s var(--ease), opacity 0.25s var(--ease); }

@media (forced-colors: active) {
  .ticket { forced-color-adjust: none; }
  .btn-fill { border: 1px solid ButtonText; }
}
