/* Home (page layer): today's conditions record, the terrain plate, the rim index and Thor's Hammer.
   The 3D and conditions scripts are unchanged; these rules only dress their hooks. */
@layer page {
  /* Phones: Home paints in the metric-matched fallback faces and plates-home.js adds .wf after load, so the terrain
     poster (the phone LCP) has the link to itself, as it did in the release. */
  @media (max-width: 899px) {
    .js body.home:not(.wf) {
      --p-serif: "Caslon Text Fallback", Georgia, "Times New Roman", serif;
      --p-display: "Caslon Display Fallback", Georgia, serif;
      --p-sans: "Franklin Fallback", "Helvetica Neue", Arial, sans-serif;
      --serif: var(--p-serif); --sans: var(--p-sans);
      --font-serif: var(--p-serif); --font-display: var(--p-display); --font-sans: var(--p-sans); --font-figures: var(--p-sans);
    }
    .js body.home.wf { --p-display: "Libre Caslon Display Late", "Caslon Display Fallback", Georgia, serif; --font-display: var(--p-display); }
  }
  .home-opener { row-gap: 28px; }
  .home-opener > .col { grid-column: 1 / span 7; align-self: end; }
  .home-opener h1 { max-width: 12ch; }

  /* The exhibit beside its label (Chase, November 30: hero option C). The terrain plate takes the right of the sheet and
     the first screen; the title, lead and Today at Bryce stack beside it, so the amphitheater shows on load. */
  @media (min-width: 901px) {
    /* --home-plate-x: where the plate starts across the sheet (column 6, or 5 from 1200px); percentages resolve against the
       opener, which is the panels' containing block. */
    .home-opener { --home-top: clamp(24px, 2.4vw, 36px); --home-plate-h: clamp(460px, calc(100svh - 220px), 820px);
      --home-plate-x: calc((100% - 11 * var(--p-gap)) * 5 / 12 + 5 * var(--p-gap));
      position: relative; padding-top: var(--home-top); row-gap: 26px; grid-template-rows: auto 1fr; align-items: start; }
    .home-opener > .col { grid-column: 1 / span 5; grid-row: 1; align-self: start; }
    .home-opener h1 { max-width: 10ch; font-size: clamp(44px, 4.2vw, 62px); }
    .home-opener .lead { font-size: 19px; }
    .home-opener > .today { grid-column: 1 / span 5; grid-row: 2; align-self: start; position: static; }
    .home-opener > .terrain-plate { grid-column: 6 / -1; grid-row: 1 / span 2; align-self: start; }
    .home-opener .terrain-plate .hero { aspect-ratio: auto; height: var(--home-plate-h); max-height: none; }
    /* A record's detail is a leaf laid on the plate, square to its top-left corner and never taller than it, so the whole
       card is in the first screen; it scrolls inside if the forecast runs long (Chase, November 30). */
    .home-opener .today .header-panel { top: var(--home-top); left: var(--home-plate-x); right: auto; margin: 0;
      width: min(560px, calc(100% - var(--home-plate-x))); max-height: var(--home-plate-h); overscroll-behavior: contain; }
    /* The road map gives up height first (cropped, not scaled), so the whole Roads leaf fits a short screen (1280 × 720). */
    .home-opener .today .header-panel .header-network-map { aspect-ratio: auto; height: clamp(140px, calc(var(--home-plate-h) - 330px), 225px); }
    /* The open row points at its leaf. */
    .today .header-module.is-expanded .dock-module-label::after { content: "→"; margin-left: 6px; }
  }
  @media (min-width: 1200px) {
    .home-opener { --home-plate-x: calc((100% - 11 * var(--p-gap)) / 3 + 4 * var(--p-gap)); }
    .home-opener > :is(.col, .today) { grid-column: 1 / span 4; }
    .home-opener > .terrain-plate { grid-column: 5 / -1; }
  }

  /* ---------- Today at Bryce: a record, not a dashboard ---------- */
  .today { grid-column: 9 / span 4; position: relative; align-self: end; }
  .today .record-title { margin-bottom: 8px; }
  .today .conditions-header { border-top: 1px solid var(--p-ink); }
  .today .header-module, .today .cameras-row { position: static; display: grid; grid-template-columns: 6.5em 1fr; gap: 4px 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--p-rule); }
  .today .dock-module-label { font: 600 var(--p-meta)/1.5 var(--p-sans); color: var(--p-ink); grid-column: 1; }
  .today .header-trigger { grid-column: 2; display: grid; gap: 2px; min-height: var(--p-hit); color: var(--p-ink); text-decoration: none; font: 400 var(--p-small)/1.45 var(--p-sans); cursor: pointer; }
  .today .header-trigger:hover .dock-weather-summary, .today .header-trigger:hover .header-road-label, .today .header-trigger:hover strong { text-decoration: underline; text-underline-offset: 3px; }
  .today .header-weather { grid-column: 1 / -1; grid-template-columns: 6.5em 1fr; column-gap: 12px; }
  .today .header-weather .dock-module-label { grid-row: 1 / span 2; }
  .today .weather-now { display: flex; align-items: center; gap: 10px; }
  .today .weather-symbol { width: 28px; height: 28px; flex: none; }
  .today .weather-symbol:empty { display: none; }
  .today .weather-symbol svg { width: 100%; height: 100%; }
  .today .weather-now strong { font: 400 28px/1 var(--p-serif); font-variant-numeric: lining-nums; margin-right: 8px; }
  .today .weather-now small { font: 400 var(--p-meta)/1.4 var(--p-sans); color: var(--p-ink-2); }
  .today .dock-weather-summary { grid-column: 2; font-size: var(--p-meta); color: var(--p-ink-2); }
  .today .header-roads { grid-column: 1 / -1; grid-template-columns: 6.5em 1fr; column-gap: 12px; }
  .today .header-roads .dock-module-label { grid-row: 1 / span 2; }
  .today .close-map { display: block; grid-column: 2; width: 100%; aspect-ratio: 380 / 154; background: var(--p-mount-2); overflow: hidden; }
  .today .close-map svg { display: block; width: 100%; height: 100%; }
  .today .header-road-label { grid-column: 2; display: flex; align-items: center; gap: 8px; font-size: var(--p-meta); }
  .today .header-road-label::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--p-rule-2); }
  .today [data-road-summary-state="clear"] .header-road-label::before { background: #2b7a4b; }
  .today [data-road-summary-state="caution"] .header-road-label::before { background: #a36a10; }
  .today [data-road-summary-state="closure"] .header-road-label::before { background: var(--p-alert); border-radius: 1px; transform: rotate(45deg); }
  .today .notices-module .header-park-notices { min-height: var(--p-hit); align-content: center; }
  .today .notice-title { display: inline-flex; align-items: center; gap: 8px; }
  .today .notice-title svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .today .notice-title strong { font: 600 var(--p-small)/1.35 var(--p-sans); }
  .today [data-notice-state="closure"] .notice-title { color: var(--p-alert); }
  .today [data-notice-state="caution"] .notice-title { color: #7a4f0c; }
  .today .cameras-row a { font: 400 var(--p-small)/1.45 var(--p-sans); color: var(--p-ink); }
  .today .actions { margin-top: 14px; }
  /* What is reported, in the provider's own first sentence: the leading road reports and park notice. */
  .today .header-road-detail { grid-column: 2; display: grid; gap: 4px; margin-top: 2px; font: 400 var(--p-meta)/1.4 var(--p-sans); color: var(--p-ink-2); }
  .today .notice-line { font: 400 var(--p-meta)/1.4 var(--p-sans); color: var(--p-ink-2); }
  .today .weather-outlook { grid-column: 2; font: 400 var(--p-meta)/1.4 var(--p-sans); color: var(--p-ink-2); }
  .today :is(.header-road-detail, .notice-line, .weather-outlook)[hidden] { display: none; }

  /* Panels open below the record (header-panels.js toggles [hidden]). Paper, a hairline, no shadow. */
  .today .header-panel { position: absolute; z-index: 6; top: 100%; right: 0; width: min(560px, calc(100vw - 32px)); max-height: min(78vh, 720px); overflow: auto;
    margin-top: 8px; padding: 18px 20px; background: var(--p-white); border: 1px solid var(--p-ink); color: var(--p-ink); font: 400 var(--p-small)/1.5 var(--p-sans); }
  .today .header-panel[hidden] { display: none; }
  .today .header-panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .today .header-panel-title { font: 400 24px/1.2 var(--p-serif); margin: 0; }
  .today .header-panel-heading button { width: var(--p-hit); height: var(--p-hit); border: 0; background: transparent; font: 400 26px/1 var(--p-sans); color: var(--p-ink); cursor: pointer; }
  .today .header-panel-heading button:hover { background: var(--p-mount-2); }
  .today .header-panel-note { font: 400 var(--p-meta)/1.5 var(--p-sans); color: var(--p-ink-2); margin: 6px 0; }
  .today .header-panel-label { font: 600 var(--p-meta)/1.4 var(--p-sans); margin: 16px 0 6px; }
  .today .weather-details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 12px 0; border-top: 1px solid var(--p-rule); }
  .today .weather-details div { padding: 8px 0; border-bottom: 1px solid var(--p-rule); }
  .today .weather-details dt { font: 400 var(--p-meta)/1.3 var(--p-sans); color: var(--p-ink-2); }
  .today .weather-details dd { margin: 2px 0 0; font: 600 var(--p-small)/1.3 var(--p-sans); }
  .today .header-forecast-periods { display: grid; gap: 8px; }
  .today .header-forecast-periods article { display: grid; grid-template-columns: 32px 1fr; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--p-rule); }
  .today .header-forecast-periods article > *:not(svg, .forecast-icon) { grid-column: 2; }
  .today .header-forecast-periods svg, .today .forecast-icon { width: 28px; height: 28px; grid-row: 1 / span 2; }
  .today .header-forecast-periods strong { font: 600 var(--p-small)/1.35 var(--p-sans); }
  .today .header-forecast-periods p { margin: 0; font: 400 var(--p-meta)/1.5 var(--p-sans); color: var(--p-ink-2); }
  .today .header-panel-links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 14px; }
  .today .header-panel-links a { display: inline-flex; align-items: center; min-height: var(--p-hit); font: 500 var(--p-small)/1.3 var(--p-sans); color: var(--p-ink); }
  .today .header-network-map { display: block; width: 100%; height: auto; aspect-ratio: 760 / 330; background: var(--p-mount-2); margin: 10px 0; }
  .today .header-local-reports p { font: 400 var(--p-meta)/1.5 var(--p-sans); margin: 0; padding: 6px 0; border-top: 1px solid var(--p-rule); }
  .today .header-notice-detail { padding: 10px 0; border-bottom: 1px solid var(--p-rule); }
  .today .header-notice-detail :is(h3, .header-notice-title) { font: 600 var(--p-small)/1.4 var(--p-sans); margin: 0 0 4px; }
  .today .header-notice-detail > p { font: 400 var(--p-meta)/1.5 var(--p-sans); margin: 0; }

  /* Road maps (local, expanded and the dialog): the map's own colors, on mount gray. */
  :is(.today, .header-map-dialog) .map-road { fill: none; stroke: #8b918c; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
  :is(.today, .header-map-dialog) .map-report { fill: none; stroke-width: 3; stroke-linecap: round; vector-effect: non-scaling-stroke; }
  :is(.today, .header-map-dialog) .map-town { font-family: var(--p-sans); font-size: 11px; fill: var(--p-ink); stroke: var(--p-mount-2); stroke-width: 3px; paint-order: stroke; }
  :is(.today, .header-map-dialog) .map-label { font: 600 10px var(--p-sans); fill: var(--p-ink); stroke: var(--p-mount-2); stroke-width: 4px; paint-order: stroke; }
  :is(.today, .header-map-dialog) .map-label.map-park-label { font-size: 15px; font-weight: 700; stroke: none; }
  :is(.today, .header-map-dialog) .map-dot { fill: var(--p-ink); stroke: #fff; stroke-width: 1.5; }
  :is(.today, .header-map-dialog) .map-park { fill: var(--p-accent); stroke: #fff; stroke-width: 1.5; }
  :is(.today, .header-map-dialog) .map-park-boundary { fill: #8eaa7b; fill-opacity: .3; stroke: #526e44; stroke-width: 1.3; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
  .today .header-panel .map-town { font-size: 16px; }
  .header-map-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0; font: 400 var(--p-meta)/1.5 var(--p-sans); }
  .road-key { display: inline-flex; align-items: center; gap: 6px; font: 500 var(--p-min)/1.4 var(--p-sans); }
  .road-key::before { content: ""; width: 14px; height: 3px; background: #8b918c; }
  .road-key.clear::before { background: #2b8050; }
  .road-key.caution::before { background: #b27616; }
  .road-key.closure::before { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(#fffaf0, #fffaf0) center / 7px 2px no-repeat, #b73535; }

  .header-map-dialog { width: 1280px; max-width: calc(100% - 32px); max-height: calc(100dvh - 32px); margin: auto; padding: 0; border: 1px solid var(--p-ink); background: var(--p-paper); color: var(--p-ink); overflow: auto; }
  .header-map-dialog::backdrop { background: rgb(26 26 23 / .82); }
  .header-map-dialog-bar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 16px 24px; border-bottom: 1px solid var(--p-rule); }
  .header-map-dialog-bar p { font: 500 var(--p-meta)/1.4 var(--p-sans); color: var(--p-ink-2); margin: 0 0 4px; }
  .header-map-dialog h2 { font: 400 28px/1.15 var(--p-serif); margin: 0; }
  .header-map-dialog button { min-height: var(--p-hit); padding: 0 16px; border: 1px solid var(--p-ink); background: transparent; color: var(--p-ink); font: 600 var(--p-small)/1 var(--p-sans); cursor: pointer; }
  .header-expanded-layout { display: grid; grid-template-columns: 2fr 1fr; }
  .header-expanded-layout > div:first-child { padding: 16px; min-width: 0; }
  .header-expanded-layout svg { display: block; width: 100%; max-height: 65dvh; background: var(--p-mount-2); }
  .header-map-note { font: 400 var(--p-meta)/1.6 var(--p-sans); color: var(--p-ink-2); margin: 10px 0 0; }
  .header-regional-reports { padding: 20px; border-left: 1px solid var(--p-rule); max-height: 75dvh; overflow: auto; font: 400 var(--p-meta)/1.5 var(--p-sans); }
  .header-regional-reports article { padding: 12px 0; border-bottom: 1px solid var(--p-rule); }
  .header-regional-reports h3 { font: 600 var(--p-small)/1.4 var(--p-sans); margin: 0 0 4px; }
  .header-regional-reports small { font-size: var(--p-min); color: var(--p-ink-2); }
  .header-regional-reports > a { display: inline-flex; align-items: center; min-height: var(--p-hit); margin-top: 8px; }

  /* ---------- Plate 1: the terrain ---------- */
  .terrain-plate .mount { overflow: hidden; }
  .terrain-plate .hero { position: relative; aspect-ratio: 2 / 1; max-height: 78vh; width: 100%; background: var(--p-mount); isolation: isolate; }
  .terrain-plate .hero-poster, .terrain-plate .hero-poster img, .terrain-plate .hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
  .terrain-plate .hero-poster img { object-fit: cover; transition: opacity .8s ease; }
  .terrain-plate .hero-canvas { display: block; opacity: 0; transition: opacity .8s ease; touch-action: pan-y; cursor: grab; z-index: 2; }
  .terrain-plate .hero.is-dragging .hero-canvas { cursor: grabbing; }
  .terrain-plate .hero.is-live .hero-canvas { opacity: 1; }
  .terrain-plate .hero.is-live .hero-poster img { opacity: 0; }
  .terrain-plate .hero.is-static .hero-canvas { display: none; }
  .terrain-plate .hero-canvas:focus-visible { outline: 2px solid var(--p-accent); outline-offset: -4px; }
  .terrain-plate .mobile-terrain-start { position: absolute; z-index: 4; left: 50%; bottom: 50%; transform: translate(-50%, 50%); min-height: var(--p-hit); padding: 0 16px; border: 1px solid var(--p-ink); background: var(--p-ink); color: var(--p-paper); font: 600 var(--p-small)/1 var(--p-sans); cursor: pointer; }
  /* Pause is housekeeping, not an exhibit label: a small frosted tab in the corner, full paper on hover or focus. */
  .terrain-plate .hero-motion { position: absolute; z-index: 4; right: 10px; bottom: 10px; min-height: 28px; padding: 0 10px; border: 0; background: rgb(250 249 245 / .72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: var(--p-ink); font: 500 var(--p-min)/1 var(--p-sans); cursor: pointer; transition: background-color .2s ease; }
  .terrain-plate .hero-motion:is(:hover, :focus-visible) { background: var(--p-paper); }
  .terrain-plate .hero-motion:focus-visible { outline: 2px solid var(--p-accent); outline-offset: 2px; }
  @media (pointer: coarse) { .terrain-plate .hero-motion { min-height: var(--p-hit); padding: 0 14px; } }
  .terrain-plate .poi, .terrain-plate .model-places { font: 600 var(--p-min)/1 var(--p-sans); }

  /* ---------- The rim road ---------- */
  #places > header { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--p-gap); align-items: end; margin-bottom: 24px; }
  #places > header h2 { margin: 0; }
  #places > header p { margin: 0; font: 400 var(--p-small)/1.5 var(--p-sans); color: var(--p-ink-2); max-width: 46ch; }

  /* ---------- Plate 2: Thor's Hammer ---------- */
  .thor-section { align-items: start; }
  .thor-section .thor-plate { grid-column: 1 / span 7; }
  .thor-section .thor-text { grid-column: 9 / span 4; }
  @media (max-width: 900px) { .thor-section { display: flex; flex-direction: column; } }
  .thor-section .thor-text h2 { margin-top: 0; }
  .thor-section .record { margin: 20px 0; }
  .thor-section .record > div { grid-template-columns: 5.5em 1fr; }
  .thor-plate .landmark-stage { position: relative; aspect-ratio: 7 / 8; max-height: 86vh; width: 100%; overflow: hidden; isolation: isolate; background: var(--p-mount); }
  .thor-plate .landmark-poster, .thor-plate .landmark-poster img, .thor-plate .landmark-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
  .thor-plate .landmark-poster img { object-fit: contain; transition: opacity .8s ease; }
  .thor-plate .landmark-canvas { display: block; opacity: 0; transition: opacity .8s ease; touch-action: pan-y; cursor: grab; z-index: 2; }
  .thor-plate .landmark-stage.is-dragging .landmark-canvas { cursor: grabbing; }
  .thor-plate .landmark-stage.is-live .landmark-canvas { opacity: 1; }
  .thor-plate .landmark-stage.is-live .landmark-poster img { opacity: 0; }
  .thor-plate .landmark-stage.is-static :is(.landmark-canvas, .landmark-hud) { display: none; }
  .thor-plate .landmark-canvas:focus-visible { outline: 2px solid var(--p-accent); outline-offset: -4px; }
  .thor-plate .landmark-stage:not(.is-live) .landmark-hud { visibility: hidden; }
  .thor-plate .landmark-hud { position: absolute; z-index: 4; left: 12px; right: 12px; bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
  .thor-plate :is(.lens, .zoom) { display: flex; background: var(--p-paper); border: 1px solid var(--p-ink); }
  .thor-plate .lens button { min-height: var(--p-hit); padding: 0 12px; border: 0; background: transparent; font: 600 var(--p-meta)/1 var(--p-sans); color: var(--p-ink); cursor: pointer; }
  .thor-plate .lens button[aria-pressed="true"] { background: var(--p-ink); color: var(--p-paper); }
  .thor-plate .zoom { margin-left: auto; }
  .thor-plate .zoom button { width: var(--p-hit); height: var(--p-hit); display: grid; place-items: center; border: 0; background: transparent; color: var(--p-ink); cursor: pointer; }
  .thor-plate .zoom svg { stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
  .thor-plate :is(.lens button[aria-pressed="false"], .zoom button):hover { background: var(--p-mount-2); }
  .thor-plate .landmark-status { position: absolute; z-index: 4; left: 14px; right: 14px; top: 12px; margin: 0; font: 400 var(--p-meta)/1.4 var(--p-sans); color: var(--p-ink-2); }
  .thor-plate .landmark-status:empty { display: none; }
  .thor-plate .thor-labels { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
  .thor-plate .thor-label { position: absolute; left: 0; top: 0; white-space: nowrap; font: 600 var(--p-min)/1 var(--p-sans); color: var(--p-ink); background: var(--p-paper); border: 1px solid var(--p-ink); padding: 5px 8px; translate: 14px -50%; transition: opacity .3s; }
  .thor-plate .thor-label[data-side="-1"] { translate: calc(-100% - 14px) -50%; }
  .thor-plate .thor-label::before { content: ""; position: absolute; top: 50%; width: 12px; height: 1px; background: var(--p-ink); }
  .thor-plate .thor-label[data-side="1"]::before { right: 100%; }
  .thor-plate .thor-label[data-side="-1"]::before { left: 100%; }
  .thor-plate .thor-label.is-hidden { opacity: 0; }
  .thor-plate [data-thor-caption][hidden] { display: none; }

  @media (max-width: 900px) {
    .home-opener > .col, .today { grid-column: 1 / -1; }
    /* The opener is a flex column here, where the desktop align-self: end pushed the title block to the right edge. */
    .home-opener > .col { align-self: stretch; }
    .today { order: 3; }
    .today .header-panel { left: 0; right: 0; width: auto; }
    .terrain-plate .hero { aspect-ratio: 4 / 3; }
    #places > header { grid-template-columns: 1fr; }
    .thor-section .thor-plate, .thor-section .thor-text { grid-column: 1 / -1; }
    .thor-section .thor-text { order: -1; }
    .thor-plate .landmark-stage { aspect-ratio: 4 / 5; }
    .header-expanded-layout { grid-template-columns: 1fr; }
    .header-regional-reports { border-left: 0; border-top: 1px solid var(--p-rule); max-height: none; }
    .header-map-dialog-bar { padding: 12px; }
    .header-map-dialog h2 { font-size: 23px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .terrain-plate :is(.hero-poster img, .hero-canvas), .thor-plate :is(.landmark-poster img, .landmark-canvas), .thor-plate .thor-label { transition: none; }
  }
}
