/* The page: the chart view, the fixed bubbles, where the chart's own bubbles and the readout sit, the
 * loading hairline, the empty and error lines, and the room an open panel takes. Layout only: kit parts
 * keep their look (controls.css). Tokens only. */

.app { --inset-goal: 0px; }

/* ---------- the chart view ---------- */
/* not clipped: the bubbles' shadows fall onto the page below */
.app-view { position: relative; height: max(480px, calc(100svh - var(--peek))); }
.app-view[hidden] { display: none; }
.app-globe { position: fixed; inset: 0; z-index: calc(var(--z-fixed) - 1); background: var(--surface-paper); }
.app-briefing { position: fixed; inset: 0; z-index: calc(var(--z-fixed) - 1); background: var(--surface-paper); }
.app:not(.is-globe-open):not(.is-briefing-open) .app-globe-back { display: none; }
.app.is-globe-open .app-fixed [data-zone="tl"] > :not(.app-globe-back),
.app.is-briefing-open .app-fixed [data-zone="tl"] > :not(.app-globe-back) { display: none; }
.app.is-globe-open .app-view,
.app.is-globe-open .app-pmf,
.app.is-globe-open .app-sections,
.app.is-briefing-open .app-view,
.app.is-briefing-open .app-pmf,
.app.is-briefing-open .app-sections { display: none; }
.fc-canvas {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; outline: none;
  transition: opacity var(--dur) var(--ease-out);
}
/* new data is taking a moment: the old plot stays, dimmed */
.app-view.is-loading .fc-canvas { opacity: 0.72; }
.fc-snapshot { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* the fixed bubbles: one row over the top of the view, on screen whatever scrolls */
.app-fixed { position: fixed; inset: 0 0 auto 0; z-index: var(--z-fixed); grid-template-rows: auto; grid-template-areas: "tl tc tr"; }

/* every bubble arrives with the data, and gives way while a panel is open at the left */
.app :is(.c-zone > *, .fc-note, .fc-recenter) { transition: opacity var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
.app:not(.is-ready) :is(.c-zone > *, .fc-note) { opacity: 0; pointer-events: none; }
.app.is-inset .app-fixed [data-zone="tl"] > :not([aria-expanded="true"]),
.app.is-inset .fc-chrome [data-zone="bl"] > * { opacity: 0; transform: scale(var(--scale-enter)); pointer-events: none; }
/* the date stepper centres on the chart area that is left */
.fc-chrome [data-zone="bc"] { transition: transform var(--dur-move) var(--ease-out); }
.app.is-inset .fc-chrome [data-zone="bc"] { transform: translateX(calc(var(--inset-goal) / 2)); }

/* "Showing 5 of 9 · Show all": under the top bubbles, at the right */
.fc-note {
  position: absolute; z-index: var(--z-chrome);
  top: calc(var(--top-clear, calc(var(--inset) + var(--size-control))) + var(--space-8)); right: var(--inset);
}
.fc-note:not(.is-shown) { opacity: 0; pointer-events: none; }

/* "← Dec 27 forecast": at the edge the forecast went off */
.fc-recenter { position: absolute; z-index: var(--z-chrome); top: 50%; margin-top: calc(var(--size-control-sm) / -2); }
.fc-recenter.left { left: calc(var(--inset) + var(--inset-goal)); }
.fc-recenter.right { right: var(--inset); }
.fc-recenter:not(.is-shown) { opacity: 0; pointer-events: none; }

/* ---------- the readout: solid, under the top bubbles, placed by the chart ---------- */
.fc-readout { position: absolute; left: 0; top: 0; z-index: var(--z-chart); pointer-events: none; will-change: transform; }
.fc-readout .c-readout-name { max-width: 200px; }
.fc-readout-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.fc-readout td.fc-readout-tight { font-size: var(--text-axis); padding-left: var(--space-8); }
.fc-readout-only { margin-top: 0; padding-top: 0; border-top: 0; }
.fc-readout-misses { display: inline-flex; gap: var(--gap-dot); margin-left: var(--space-6); vertical-align: middle; }
.fc-readout-misses .c-dot { width: var(--space-6); height: var(--space-6); }
/* layer rows (features/chart/layers.js): a short stroke in the layer's ink, or a peak's mark */
.fc-readout-layers { margin-top: var(--space-6); padding-top: var(--space-6); border-top: var(--stroke-hairline) solid var(--line-hairline); }
.fc-readout-layers.fc-readout-only { margin-top: 0; padding-top: 0; border-top: 0; }
.fc-readout-layers .c-readout-name { color: var(--ink-tertiary); }
.fc-swatch { flex: none; width: var(--size-dot); height: 0; border-top: var(--stroke-layer) solid currentColor; }
.fc-swatch.is-dash { border-top-style: dashed; }
.fc-swatch.is-dot { height: var(--space-6); width: var(--space-6); border: var(--stroke-layer) solid currentColor; transform: rotate(45deg); }
.fc-swatch.is-peak { height: 0; border-top: 0; border-left: var(--space-4) solid transparent; border-right: var(--space-4) solid transparent; border-bottom: var(--space-6) solid currentColor; }

/* ---------- empty, loading, error ---------- */
.fc-empty {
  position: absolute; z-index: var(--z-chart); transform: translate(-50%, -50%);
  font-size: var(--text-small); color: var(--ink-tertiary); white-space: nowrap; pointer-events: none;
}
.app-error {
  position: absolute; inset: 0; z-index: var(--z-chrome);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-small); color: var(--ink-tertiary);
}
#app > .app-error { position: fixed; }

/* a hairline under the top edge while the first data loads; it waits a moment so a fast load shows nothing */
.app-progress {
  position: fixed; z-index: var(--z-toast); inset: 0 0 auto 0; height: var(--space-2); overflow: hidden;
  pointer-events: none; opacity: 0;
  animation: app-progress-in var(--dur) var(--ease-out) var(--dur) forwards;
}
.app-progress::before {
  content: ""; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, var(--ink-tertiary), transparent);
  animation: app-progress calc(var(--dur-move) * 4) linear infinite;
}
.app-progress.is-done { animation: none; opacity: 0; transition: opacity var(--dur) var(--ease-out); }
@keyframes app-progress-in { to { opacity: 1; } }
@keyframes app-progress { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* ---------- the date picker: season chips, then a calendar of rounds ---------- */
.dp .c-float-body { padding: var(--space-12); }
.dp-seasons { display: flex; flex-wrap: wrap; gap: var(--space-6); margin-bottom: var(--space-12); }
.dp-grid { display: grid; gap: var(--space-4); }
.dp-row { display: flex; align-items: center; gap: var(--space-4); }
.dp-month { flex: none; width: var(--space-40); font-size: var(--text-small); color: var(--ink-tertiary); }
.dp-row .c-tile { width: var(--space-40); }
.dp-foot { display: flex; justify-content: flex-end; margin-top: var(--space-8); font-size: var(--text-small); }

/* ---------- the page below the chart ---------- */
.app-sections { position: relative; z-index: var(--z-chart); max-width: 1760px; margin-inline: auto; }
.app-sec-nav {
  display: flex; align-items: baseline; gap: var(--space-20); flex-wrap: wrap;
  margin: var(--space-24) var(--space-24) 0;
  border-bottom: var(--stroke-hairline) solid var(--line-hairline);
}
.app-sec-tab {
  position: relative; margin: 0 0 calc(-1 * var(--stroke-hairline)) 0; padding: var(--space-8) 0 var(--space-10, 10px);
  border: 0; border-bottom: 1.5px solid transparent; background: none;
  font: inherit; font-size: var(--text-control); font-weight: var(--weight-medium); color: var(--ink-tertiary);
  cursor: pointer; transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.app-sec-tab:hover { color: var(--ink-primary); }
.app-sec-tab.is-active { color: var(--ink-primary); border-bottom-color: var(--ink-primary); }
.app-sec-tab[hidden] { display: none; }
.app-section { min-height: var(--peek); padding: 0 var(--space-24) var(--space-56); }
.app-section .v-section { padding-top: var(--space-24); }
.app-section[hidden] { display: none; }
.app-section.is-pending { min-height: 40svh; }
.app-section-error { color: var(--ink-tertiary); font-size: var(--text-small); padding: var(--space-24) 0; }
.app-foot {
  display: flex; justify-content: flex-end; align-items: center;
  margin: 0 var(--space-24); padding: 0 0 var(--space-24);
}
.app-foot-link {
  padding: 0; border: 0; background: none; font: inherit; font-size: var(--text-small);
  cursor: pointer;
}
.app-welcome-foot { align-self: stretch; width: auto; margin: 0; padding: 0; }
@media (min-width: 760px) {
  .app-welcome-foot { position: fixed; right: var(--space-24); bottom: var(--space-20); z-index: var(--z-chrome); width: auto; }
}
.fc-recenter { gap: var(--space-4); }
.fc-recenter-arrow { display: inline-flex; width: var(--size-icon-sm); height: var(--size-icon-sm); }
.fc-recenter-arrow[hidden] { display: none; }
.fc-recenter-arrow svg { width: 100%; height: 100%; }

/* crossing seasons by a pull past the end: the next season's name at that edge, fading in with the pull,
   primary ink once letting go will cross */
.fc-cross {
  position: absolute; z-index: var(--z-chrome); top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; gap: var(--space-4); pointer-events: none;
  font-size: var(--text-control); font-weight: var(--weight-medium); color: var(--ink-tertiary);
  opacity: 0; transition: color var(--dur-fast) var(--ease-out);
}
.fc-cross.is-shown { opacity: var(--pull, 0); }
.fc-cross.is-ready { color: var(--ink-primary); }
.fc-cross.left { left: calc(var(--inset) + var(--inset-goal)); }
.fc-cross.right { right: var(--inset); }
.fc-cross-arrow { display: inline-flex; width: var(--size-icon-sm); height: var(--size-icon-sm); }
.fc-cross-arrow svg { width: 100%; height: 100%; }

/* Layers › Past seasons: grey or tinted, two swatches at the end of the row while the layer is on */
.fc-tints { display: inline-flex; gap: var(--space-6); margin-left: auto; padding-left: var(--space-12); }
.c-menu-item[aria-checked="false"] .fc-tints { display: none; }
.fc-tint {
  width: 12px; height: 12px; border-radius: 50%; cursor: pointer; flex: none;
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
.fc-tint.is-mono { background: var(--ink-tertiary); }
.fc-tint.is-tints { background: conic-gradient(var(--season-1) 0 25%, var(--season-2) 0 50%, var(--season-3) 0 75%, var(--season-4) 0); }
.fc-tint[aria-checked="true"] { box-shadow: 0 0 0 1.5px var(--surface-raised), 0 0 0 3px var(--accent); }
.fc-tint:hover:not([aria-checked="true"]) { box-shadow: 0 0 0 1.5px var(--surface-raised), 0 0 0 3px var(--fill-selected); }

/* scrolled down until the chart's bottom bubbles reach the top bubbles: they step out of the way */
.app.is-tucked :is(.fc-chrome .c-zone > *, .fc-note, .fc-recenter, .fc-cross) { opacity: 0; pointer-events: none; }

/* ---------- zero-hub / zero-round onboarding on paper ---------- */
.app-welcome {
  min-height: 100svh; display: flex; flex-direction: column; align-items: center;
  gap: var(--space-16); padding: var(--space-32) var(--space-24) var(--space-24);
}
.app-welcome-card {
  margin: auto 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-12);
  width: min(520px, 100%); padding: var(--space-24);
  border-radius: var(--radius-panel); background: var(--surface-raised);
  border: var(--stroke-hairline) solid var(--line-hairline);
}
.app-welcome-section { align-self: stretch; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-8); }
.app-welcome-label { font-size: var(--text-micro); font-weight: var(--weight-medium); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-tertiary); }
.app-welcome-hubs { align-self: stretch; display: flex; flex-direction: column; }
.app-welcome-hub-tools {
  align-self: stretch; display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-12); padding: 0 0 var(--space-6);
}
.app-welcome-hub-tools:empty { display: none; }
.app-welcome-hub {
  display: flex; align-items: center; gap: var(--space-12); padding: var(--space-8) 0;
  border-top: var(--stroke-hairline) solid var(--line-hairline);
}
.app-welcome-hub-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.app-welcome-hub-name { font-size: var(--text-control); font-weight: var(--weight-medium); color: var(--ink-primary); }
.app-welcome-hub-meta { font-size: var(--text-small); color: var(--ink-tertiary); font-variant-numeric: tabular-nums; }
.app-welcome-hub-meta.is-error { color: var(--status-error); }
.app-welcome-title {
  margin: 0; font-size: var(--text-title); font-weight: var(--weight-strong);
  color: var(--ink-primary); letter-spacing: -0.01em;
}
.app-welcome-sub {
  margin: 0; font-size: var(--text-body); line-height: 1.5; color: var(--ink-secondary);
}
.app-welcome-actions { display: flex; flex-wrap: wrap; gap: var(--space-8); margin-top: var(--space-4); }
.app-welcome-cmd {
  padding: var(--space-6) var(--space-8); border-radius: var(--radius-tag);
  background: var(--fill-field); font-family: var(--font-mono); font-size: var(--text-small);
  color: var(--ink-secondary); user-select: all;
}

/* ---------- first-visit onboarding dialog (web mode, shown once per browser) ---------- */
.ob-backdrop {
  position: fixed; inset: 0; z-index: var(--z-popover);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-24);
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(4px);
}
:root[data-theme="light"] .ob-backdrop { background: rgba(15, 23, 42, 0.34); }
.ob-card {
  width: min(460px, 100%); max-height: min(90svh, 640px); overflow-y: auto;
  padding: var(--space-24);
  border-radius: var(--radius-panel);
  background: var(--surface-raised);
  border: var(--stroke-hairline) solid var(--line-hairline);
  box-shadow: var(--shadow-raised);
  display: flex; flex-direction: column; gap: var(--space-16);
}
.ob-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); }
.ob-title {
  margin: 0; font-size: var(--text-title); font-weight: var(--weight-strong);
  color: var(--ink-primary); letter-spacing: -0.01em;
}
.ob-close {
  display: grid; place-items: center;
  width: var(--size-control-sm); height: var(--size-control-sm); padding: 0;
  border: 0; border-radius: var(--radius-pill); background: transparent;
  color: var(--ink-tertiary); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ob-close:hover { background: var(--fill-hover); color: var(--ink-primary); }
.ob-sub { margin: 0; font-size: var(--text-body); line-height: 1.5; color: var(--ink-secondary); }
.ob-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
  border-top: var(--stroke-hairline) solid var(--line-hairline);
}
.ob-item {
  padding: var(--space-12) 0;
  border-bottom: var(--stroke-hairline) solid var(--line-hairline);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.ob-item-title { font-size: var(--text-control); font-weight: var(--weight-medium); color: var(--ink-primary); }
.ob-item-desc { font-size: var(--text-small); line-height: 1.45; color: var(--ink-tertiary); }
.ob-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-16); padding-top: var(--space-4); }
.ob-primary {
  height: var(--size-control-inner); padding: 0 var(--space-16);
  border: 0; border-radius: var(--radius-pill);
  background: var(--accent); color: var(--on-accent);
  font: inherit; font-size: var(--text-control); font-weight: var(--weight-medium);
  cursor: pointer; transition: filter var(--dur-fast) var(--ease-out);
}
.ob-primary:hover { filter: brightness(1.08); }
.ob-link { padding: 0; border: 0; background: none; font: inherit; font-size: var(--text-control); cursor: pointer; }

/* ---------- responsive layout (strictly outside 1150-1760px laptop benchmark) ---------- */
@media (max-height: 600px) {
  .app-view { height: max(320px, calc(100svh - var(--peek))); }
}
@media (max-width: 600px) {
  .app-sec-nav { margin: var(--space-16) var(--space-12) 0; gap: var(--space-12); }
  .app-section { padding: 0 var(--space-12) var(--space-40); }
  .app-foot { margin: 0 var(--space-12); }
}
@media (max-width: 440px) {
  .dp .c-float-body { overflow-x: auto; }
  .dp-row .c-tile { width: var(--space-32); }
}
