/* Address profile v2: summary rows.
   plans/address-profile-redesign.md, design spec in
   plans/mockups/address-profile-redesign/design-spec.md (approved by Spencer
   2026-11-19; ClickUp wdu9v7djea). Loaded only when single-address_profile-v2.php
   serves the page (option coc_addr_layout). Built from the mockup's stylesheet;
   uses the theme's tokens (--color-*, --nh-header-h) and adds no new colours. */

.apv2 { --apv2-line: #e5e7eb; --apv2-top: var(--nh-header-h, 72px); }

/* ---------- slot 1 ---------- */
/* Right after the quick facts: AdSense unit 1 until a sponsor is live (the
   compact sponsor card then sits above <main>, as on today's page). The
   theme's 80 px section padding above the first card is cut back so the slot
   sits close under the quick facts. */
.coc-address-page.apv2 { padding-top: 28px; }
.apv2-topslot { margin: 0 0 24px; }

/* Ad slots keep their height while the unit fills in, so the rows below do
   not jump. */
.apv2-topslot .coc-ad, .apv2-slot .coc-ad { min-height: 250px; }
@media (min-width: 768px) {
  .apv2-topslot .coc-ad, .apv2-slot .coc-ad { min-height: 90px; }
}

/* ---------- groups (H2 level) ---------- */
.apv2-group { margin: 28px 0 0; }
.apv2-tools + .apv2-group { margin-top: 20px; }
.apv2-group__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 10px; min-height: 40px;
}
.apv2-group__title {
  margin: 0; font-size: 1.25rem; line-height: 1.25; font-weight: 800;
  letter-spacing: -0.01em; color: var(--color-navy, #0f172a);
}
.apv2-group__note { margin: -4px 0 10px; font-size: 0.875rem; color: var(--color-body, #475569); }

/* ---------- "On this page" jump links and Show all ---------- */
.apv2-tools {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 4px 0 0;
}
.apv2-jump { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 0.875rem; min-width: 0; }
.apv2-jump__label { font-weight: 700; color: var(--color-navy, #0f172a); }
.apv2 .apv2-jump a {
  display: inline-flex; align-items: center; min-height: 32px;
  color: var(--color-navy, #0f172a); text-decoration: underline; text-underline-offset: 3px;
}
.apv2 .apv2-jump a:hover { color: var(--color-primary-deep, #a31919); }
.apv2-all {
  flex: 0 0 auto; font: inherit; font-size: 0.875rem; font-weight: 700;
  color: var(--color-primary-deep, #a31919); background: #fff;
  border: 1px solid var(--color-primary, #cf2627); border-radius: 999px;
  padding: 8px 14px; min-height: 40px; cursor: pointer;
}
.apv2-all:hover { background: var(--color-pink-bg, #fef2f2); }

/* ---------- summary rows ---------- */
.apv2-rows { border: 1px solid var(--apv2-line); border-radius: 12px; background: #fff; }
.apv2-row + .apv2-row { border-top: 1px solid var(--apv2-line); }
/* The label (an h3), the headline and the toggle are direct children of the
   summary. Phones: label and Show on one line, the headline under them at
   full width. */
.apv2-row__bar {
  list-style: none; cursor: pointer;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label toggle" "fact fact";
  column-gap: 12px; row-gap: 2px; align-items: center;
  min-height: 60px; padding: 10px 16px 12px; background: #fff;
}
.apv2-row__bar::-webkit-details-marker { display: none; }
.apv2-row:first-child > .apv2-row__bar { border-radius: 12px 12px 0 0; }
.apv2-row:last-child:not([open]) > .apv2-row__bar { border-radius: 0 0 12px 12px; }
.apv2-row:only-child:not([open]) > .apv2-row__bar { border-radius: 12px; }
.apv2-row__bar:hover { background: var(--color-bg, #f8fafc); }
.apv2-row__label { grid-area: label; }
.apv2-row__fact { grid-area: fact; }
.apv2-row__toggle { grid-area: toggle; }
.apv2-row__extra { display: none; }
.apv2 .apv2-row__label {
  margin: 0; font-size: 0.9375rem; line-height: 1.3; font-weight: 700; letter-spacing: 0;
  color: var(--color-navy, #0f172a);
}
.apv2-row__fact {
  min-width: 0; font-size: 0.9375rem; line-height: 1.35; color: var(--color-body, #475569);
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
/* Names may wrap; figures never do. */
.apv2-row__fact b { font-weight: 700; color: var(--color-navy, #0f172a); white-space: nowrap; }
/* "Show" is the site's red button, the same red as Download PDF, so every
   row's control is easy to find (Spencer, 2026-11-19). An open row's "Hide"
   is the outline version. */
.apv2-row__toggle {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: 0.8125rem; font-weight: 700; color: #fff;
  padding: 6px 8px 6px 12px; border: 1px solid var(--color-primary, #cf2627); border-radius: 999px;
  background: var(--color-primary, #cf2627);
}
.apv2-row__bar:hover .apv2-row__toggle { background: var(--color-primary-hover, #b91c1c); border-color: var(--color-primary-hover, #b91c1c); }
.apv2-row[open] > .apv2-row__bar .apv2-row__toggle,
.apv2-row[open] > .apv2-row__bar:hover .apv2-row__toggle {
  background: #fff; color: var(--color-primary-deep, #a31919); border-color: var(--color-primary, #cf2627);
}
.apv2-row__toggle svg { width: 18px; height: 18px; transition: transform 0.15s ease; }
.apv2-row__toggle [data-hide] { display: none; }
.apv2-row[open] > .apv2-row__bar .apv2-row__toggle [data-show] { display: none; }
.apv2-row[open] > .apv2-row__bar .apv2-row__toggle [data-hide] { display: inline; }
.apv2-row[open] > .apv2-row__bar .apv2-row__toggle svg { transform: rotate(180deg); }

/* The open row's bar stays under the site header while its card is on screen,
   so "Hide" is always one tap away and the reader keeps their place. */
.apv2-row[open] > .apv2-row__bar {
  position: sticky; top: var(--apv2-top); z-index: 5;
  background: var(--color-bg, #f8fafc); border-bottom: 1px solid var(--apv2-line);
}
/* The panel is its own layer below the bar: the map's panes carry z-indexes
   up to 1000 and would otherwise paint over the stuck bar. */
.apv2-row__panel { padding: 0 16px 16px; position: relative; z-index: 0; }
/* Anything focusable inside an open row scrolls clear of the site header and
   the stuck bar (the bar is up to 121 px tall at 320 px wide). */
.apv2 .apv2-row__panel :is(a, button, summary, input, select, textarea, [tabindex]) {
  scroll-margin-top: calc(var(--apv2-top) + 130px);
}
/* Phones: and clear of the floating "Look up another address" pill at the
   bottom (address-cta-sticky.css: 48 px tall, 12 px up). */
@media (max-width: 767px) {
  .apv2 :is(a, button, summary, input, select, textarea, [tabindex]) {
    scroll-margin-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }
}
/* Short or heavily zoomed screens: nothing sticks, so the content keeps the room. */
@media (max-height: 30em) {
  .apv2-row[open] > .apv2-row__bar { position: static; }
}

/* Phones: an open row's bar is the label and Hide only. Its headline is the
   first thing in the card just below, and a shorter bar leaves more room. */
@media screen and (max-width: 767px) {
  .apv2-row[open] > .apv2-row__bar { min-height: 52px; padding-bottom: 10px; }
  .apv2-row[open] > .apv2-row__bar .apv2-row__fact { display: none; }
}

/* A row with nothing to open (an address with no permits). */
.apv2-row--static > .apv2-row__bar { cursor: default; grid-template-columns: minmax(0, 1fr); grid-template-areas: "label" "fact"; }
/* Same line height as a label that sits beside a Show pill, so every row spaces alike. */
.apv2-row--static .apv2-row__label { min-height: 34px; display: flex; align-items: center; }
.apv2-row--static > .apv2-row__bar:hover { background: #fff; }

/* Today's cards sit inside a row unchanged; the row is the frame, so the card
   drops its own frame and its repeated title (the row label is the heading). */
.apv2-row__panel > .coc-card {
  border: 0; box-shadow: none; border-radius: 0; padding: 0; margin: 12px 0 0; background: transparent;
}
.apv2-row__panel > .coc-card .coc-card__title { display: none; }
.apv2-row__panel > .coc-card .coc-card__head { margin-bottom: 0.5rem; }

@media (min-width: 768px) {
  .apv2-row__bar {
    min-height: 56px; padding: 10px 20px; column-gap: 20px;
    grid-template-columns: 190px minmax(0, 1fr) auto; grid-template-areas: "label fact toggle";
  }
  .apv2-row--static > .apv2-row__bar { grid-template-columns: 190px minmax(0, 1fr); grid-template-areas: "label fact"; }
  .apv2-row--static .apv2-row__label { min-height: 0; display: block; }
  .apv2-row__panel { padding: 0 20px 20px; }
  .apv2-group__title { font-size: 1.375rem; }
}
/* Desktop: the second-rank detail of each row lines up in a right-hand column
   beside Show, so a closed row uses the full width. */
@media (min-width: 1024px) {
  .apv2-row__bar { grid-template-columns: 190px minmax(0, 1fr) minmax(0, auto) auto; grid-template-areas: "label fact extra toggle"; }
  .apv2-row--static > .apv2-row__bar { grid-template-columns: 190px minmax(0, 1fr); grid-template-areas: "label fact"; }
  .apv2-row__extra {
    display: block; grid-area: extra; justify-self: end; text-align: right; max-width: 380px;
    font-size: 0.875rem; line-height: 1.35; color: var(--color-body, #475569); font-variant-numeric: tabular-nums;
  }
}

/* The always-visible blocks between and after the groups (ads, or the full
   sponsor card in the last slot). */
.apv2-slot { margin: 28px 0 0; }

/* Today's "Show all N inspections" link, restyled as the same fold button as
   the other lists (the card's markup is unchanged). */
.apv2 .coc-permit-timeline__more > summary {
  list-style: none; display: flex; align-items: center; justify-content: center; cursor: pointer;
  min-height: 44px; padding: 8px 14px; font-size: 0.875rem; font-weight: 600;
  color: var(--color-navy, #0f172a); background: var(--color-bg, #f8fafc);
  border: 1px solid var(--color-slate, #cbd5e1); border-radius: 10px;
}
.apv2 .coc-permit-timeline__more > summary::-webkit-details-marker { display: none; }
.apv2 .coc-permit-timeline__more[open] > summary { display: none; }

/* A short explanatory note inside a card (what a "Fail" inspection is). */
.apv2-note {
  margin: 0 0 12px; padding: 8px 12px; font-size: 0.8125rem; line-height: 1.45;
  color: var(--color-body, #475569); background: var(--color-bg, #f8fafc);
  border: 1px solid var(--apv2-line, #e5e7eb); border-radius: 8px;
}

/* ---------- folds inside a card ("Show all N") ---------- */
.apv2-fold { margin-top: 0.75rem; }
.apv2-fold > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 14px; font-size: 0.875rem; font-weight: 600;
  color: var(--color-navy, #0f172a); background: var(--color-bg, #f8fafc);
  border: 1px solid var(--color-slate, #cbd5e1); border-radius: 10px;
}
.apv2-fold > summary::-webkit-details-marker { display: none; }
.apv2-fold[open] > summary { display: none; }
.apv2-fold > :not(summary) { margin-top: 0.75rem; }
.apv2-fold-hidden { display: none !important; }
.apv2-fold-btn {
  display: flex; align-items: center; justify-content: center; width: 100%; margin-top: 0.75rem;
  min-height: 44px; padding: 8px 14px; font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer;
  color: var(--color-navy, #0f172a); background: var(--color-bg, #f8fafc);
  border: 1px solid var(--color-slate, #cbd5e1); border-radius: 10px;
}

/* ---------- focus ---------- */
/* The theme's `.nh-main a:focus-visible` outranks a single class, so the
   components state their rings with the .apv2 parent. */
.apv2 .apv2-row__bar:focus-visible,
.apv2 .apv2-all:focus-visible,
.apv2 .apv2-fold > summary:focus-visible,
.apv2 .coc-permit-timeline__more > summary:focus-visible,
.apv2 .apv2-fold-btn:focus-visible {
  outline: 3px solid #1d4ed8; outline-offset: -3px; border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .apv2-row__toggle svg { transition: none; }
}
@media (forced-colors: active) {
  .apv2-row__toggle { border-color: ButtonText; }
}

/* ---------- print: everything open, controls and ads gone ---------- */
@media print {
  .apv2-row__toggle, .apv2-tools, .apv2-fold > summary, .apv2-fold-btn,
  .apv2 .coc-permit-timeline__more > summary,
  /* The slots hold an ad or the sponsor card, and neither prints. Hide the
     wrapper too: address-actions.css borders every child of the page, so an
     empty wrapper would print as an empty box. */
  .apv2-topslot, .apv2-slot { display: none !important; }
  .apv2-fold-hidden { display: revert !important; }
  /* Closed rows and folds print open even if the script never ran
     (Chrome 131+, Safari 18.4+, Firefox 143+); the script covers the rest. */
  .apv2-row:not([open])::details-content,
  .apv2-fold:not([open])::details-content,
  .apv2 .coc-permit-timeline__more:not([open])::details-content {
    content-visibility: visible !important; display: block !important; height: auto !important;
  }
  main.coc-address-page > .apv2-group {
    border: 0 !important; padding: 0 !important; margin: 0 0 12pt 0 !important;
    break-inside: auto !important; page-break-inside: auto !important;
  }
  .apv2-group__head { break-after: avoid; margin: 0 0 6pt; min-height: 0; }
  .apv2-group__title { font-size: 15pt !important; font-weight: 800; color: #111; margin: 0 0 6pt; }
  .apv2-rows { border: 0; }
  .apv2-row { border: 1px solid #ccc !important; border-radius: 4pt; margin: 0 0 8pt; }
  .apv2-row + .apv2-row { border-top: 1px solid #ccc; }
  .apv2-row__bar {
    position: static !important; min-height: 0; padding: 6pt 10pt; background: #f3f4f6 !important;
    border-bottom: 1px solid #ccc; break-after: avoid; border-radius: 0 !important;
  }
  .apv2-row__bar { grid-template-areas: "label fact extra" !important; grid-template-columns: max-content minmax(0, 1fr) auto !important; column-gap: 12pt; align-items: baseline; }
  .apv2-row__fact { display: inline !important; }
  .apv2-row__extra { display: block !important; grid-area: extra; font-size: 9pt; color: #333; text-align: right; }
  .apv2-row__label { font-size: 11pt; }
  .apv2-row__fact { font-size: 10pt; }
  .apv2-row__panel { padding: 0 10pt 8pt; }
  .apv2-row__panel > .coc-card {
    border: 0 !important; padding: 0 !important; margin: 6pt 0 0 !important;
    break-inside: auto; page-break-inside: auto;
  }
  .apv2-row__panel .coc-permit-tile, .apv2-row__panel .coc-schools__board { break-inside: avoid; }
  .apv2-row__panel > .coc-card--hero-map { break-after: auto; page-break-after: auto; }
  /* The map is one picture: move it, with its row's heading line and caption,
     to the next page rather than cut it or leave the heading behind. */
  .apv2-row__panel .coc-hero-map,
  .apv2-row#map { break-inside: avoid; page-break-inside: avoid; }
}
