/* =============================================================================
   View-level layout: hero, Discover, Leaderboard, Submit, Detail.
   Rules: 04-layout-and-spacing.md, 09-page-blueprints.md, 06-motion.md.
   ============================================================================= */

/* ---- Hero (variant A, DECISIONS.md 6) ----------------------------------- */
/* White page, headline beside a contained sphere panel. Text never sits on the
   gradient, so contrast cannot depend on where the gradient lands. */
/* 04-layout-and-spacing.md asks for 1.5 to 2 times --section-space above and
   below the hero. Taken literally that is written for a marketing page: on an
   app viewport it pushed the hero 100-250px past the fold at every landscape
   resolution, so nothing below it was ever visible. The vh bounds keep the
   generous ratio on tall screens and tighten it on short ones, so the next
   section's edge always shows and invites the scroll. */
.hero {
  /* Open space above the headline, but not a screenful: 20vh plus the hero's own
     bottom padding plus the tile row's left a dead band with nothing in it. */
  padding-block: min(var(--section-space), 14vh) var(--space-6);
}
.hero-grid { display: grid; gap: var(--space-7); align-items: center; }
@media (min-width: 1024px) { .hero-grid { grid-template-columns: 1fr 1fr; gap: var(--space-8); } }

/* The brand puts a lot of air under a display headline; the 16px stack rhythm
   is too tight here. */
.hero-copy > * + * { margin-top: var(--space-6); }
.hero-copy .hero-actions { margin-top: var(--space-7); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-5); }

/* No panel fill and no frame. A light-grey block reads as a seam against the
   white page and hides the background grid behind it; the brand's imagery sits
   in open space. The spheres are composed to fit inside the viewBox, so nothing
   needs clipping and the grid stays visible right through the artwork. */
.sphere-panel { position: relative; aspect-ratio: 4 / 3; }
.sphere-panel svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* One orchestrated moment on first load: fade and an 8px rise, staggered 60ms.
   Happens once. Reduced motion zeroes the durations in tokens.css, and the
   block below removes the transform entirely. */
.rise { opacity: 0; transform: translateY(8px); animation: rise var(--duration-slow) var(--ease-standard) forwards; }
.rise-1 { animation-delay: 0ms; }
.rise-2 { animation-delay: 60ms; }
.rise-3 { animation-delay: 120ms; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* Ambient drift on the hero gradient. Paused when the tab is hidden (app.js). */
.sphere-group { animation: drift var(--duration-ambient) var(--ease-standard) infinite alternate; transform-origin: 50% 50%; }
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-2%, 1.5%, 0) scale(1.04); }
}
.is-hidden-tab .sphere-group { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .rise { opacity: 1; transform: none; animation: none; }
  .sphere-group { animation: none; }
}

/* ---- Discover ----------------------------------------------------------- */
/* Totals computed from the feed. The whole band is hidden until it has real
   numbers, and stays hidden if the feed is unavailable. */
.totals { padding-block: var(--space-6); }
.totals-list {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: var(--space-5) var(--space-6); list-style: none;
}
@media (min-width: 768px) { .totals-list { grid-template-columns: repeat(4, 1fr); } }
.total-value { display: block; font-size: var(--text-h2); font-weight: var(--weight-semibold); line-height: 1.1; font-variant-numeric: tabular-nums; }
.total-label { display: block; font-size: var(--text-small); color: var(--color-text-muted); margin-top: var(--space-1); }

/* Featured: a two-column feature, big text left, real metrics right,
   separated by hairlines. No box. */
.featured-grid { display: grid; gap: var(--space-6); }
@media (min-width: 1024px) { .featured-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-8); } }

.filters { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; }
/* An author display rule beats the UA [hidden] { display: none }, so any element
   toggled with the hidden attribute needs its own guard. Without this the filter
   bar renders even when there is no data to filter. */
.filters[hidden] { display: none; }
.filter { display: grid; gap: var(--space-2); }
.filter-label { font-size: var(--text-caption); font-weight: var(--weight-semibold); color: var(--color-text-muted); }
.filter select {
  min-height: 44px; padding: var(--space-2) var(--space-3);
  font: inherit; font-size: var(--text-small);
  color: var(--color-text); background: var(--color-bg);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-control);
}
.filter select:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ---- Leaderboard -------------------------------------------------------- */

/* ---- Submit ------------------------------------------------------------- */
.form-step { display: none; }
.form-step.active { display: block; }
.form-grid { display: grid; gap: var(--space-5); }
@media (min-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } }
.form-grid.cols-2 .field + .field { margin-top: 0; }

.success-panel { display: none; }
.success-panel.active { display: block; }
.success-actions { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: var(--space-6); }

/* Forms may switch the grid off in their own section when it competes with
   text (permitted by 04-layout-and-spacing.md). Kept on; one line turns it off:
   .view-submit { --grid-line: transparent; --grid-rail: transparent; } */

/* ---- Detail ------------------------------------------------------------- */
.detail-grid { display: grid; gap: var(--space-7); }
@media (min-width: 1024px) { .detail-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-8); } }
.detail-body > * + * { margin-top: var(--space-7); }
/* The markup uses <h2 class="h3">: match the element, not the type-scale class,
   or this spacing silently never applies. */
.detail-body h2 { margin-bottom: var(--space-4); }
.detail-body p + p { margin-top: var(--space-4); }
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-small); margin-bottom: var(--space-5); }

/* ===========================================================================
   Compact task views. See the "task views versus marketing views" note in
   04-layout-and-spacing.md.
   =========================================================================== */

/* ---- Submit ------------------------------------------------------------- */
.form-width { max-width: var(--container-form); margin-inline: auto; }

/* The step count lives in the stepper row rather than on a line of its own. */
.stepper-row {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: var(--space-4);
  margin-bottom: var(--task-space);
  padding-bottom: var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
}
.stepper-row .stepper { margin-bottom: 0; }

/* Short fields pair up from 768px. DOM order is unchanged: the pairs are
   wrappers, so the tab order still runs down the form. */
@media (min-width: 768px) {
  .field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
  .field-pair > .field { margin-top: 0; }
  .field-pair + .field { margin-top: var(--space-5); }
}

/* Industry is a long single-choice list: pack it densely so it does not own
   the whole screen. Textareas and the choice groups stay full width. */
@media (min-width: 768px) { .choice-grid.cols-dense { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .choice-grid.cols-dense { grid-template-columns: repeat(4, 1fr); } }
.choice-grid.cols-dense .choice { padding-block: var(--space-2); min-height: 2.5rem; }
.choice-grid.cols-dense .choice:has(input:checked) { padding-block: calc(var(--space-2) - 1px); }

/* ---- Leaderboard -------------------------------------------------------- */
/* From 1024px the table takes the left column and the module bars sit in a
   sticky column at the right, so the bars stay in view while rows scroll. */
.board-grid { display: grid; gap: var(--task-space); }
@media (min-width: 1024px) {
  .board-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-7); align-items: start; }
  .board-side { position: sticky; top: calc(var(--nav-h) + var(--space-5)); }
}
.board-cta {
  display: flex; flex-wrap: wrap; gap: var(--space-5);
  align-items: center; justify-content: space-between;
  margin-top: var(--task-space);
  padding-top: var(--space-5);
  border-top: var(--border-width) solid var(--color-border);
}

.section-head-flush { margin-bottom: 0; }
.stepper-row .step-count { margin-bottom: 0; }
.detail-note { margin-bottom: var(--space-3); }

/* Task views trim the heading rhythm too. */
.section-task .detail-body > * + * { margin-top: var(--task-space); }
.section-task .detail-body h2 { margin-bottom: var(--space-3); }

/* Contributor cell: name over team or practice, as the previous board had it. */
.board-name { display: block; font-weight: var(--weight-semibold); }
.board-practice {
  display: block; margin-top: 2px;
  font-size: var(--text-caption); color: var(--color-text-muted);
}
.board-rank { font-variant-numeric: tabular-nums; color: var(--color-text-muted); }

/* The stepper shares the task header, so it carries no rule or margin of its own. */
.task-head .stepper-row {
  margin-top: var(--space-4);
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

/* Field rhythm inside the wizard. 24px between fields is the general rule in
   04-layout-and-spacing.md; task views tighten it so step 1 fits the 1280x600
   design viewport without scrolling. */
.form-width { --field-gap: 1.25rem; }
.form-width .field + .field,
.form-width .field + .field-pair,
.form-width .field-pair + .field,
.form-width .field-pair + .field-pair { margin-top: var(--field-gap); }
@media (min-width: 768px) {
  .form-width .field-pair + .field { margin-top: var(--field-gap); }
}

/* The gap rule above also matches the second column inside a pair, which added
   a row of slack to every paired field. Higher specificity resets it. */
.form-width .field-pair > .field + .field { margin-top: 0; }

/* Compaction for the 1280x600 design viewport. */
.form-width { --field-gap: 1rem; }
.form-width .task-head { padding-bottom: var(--space-3); margin-bottom: var(--space-5); }
.form-width .task-head .stepper-row { margin-top: var(--space-2); }
.form-width .intro-task { font-size: var(--text-caption); margin-top: var(--space-1); }
.form-width .field-label { margin-bottom: 0.375rem; }
.form-width .action-bar { padding-block: var(--space-3); padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); }
#view-submit .section-task { padding-top: var(--space-3); }
.form-width .task-head { margin-bottom: var(--space-4); }
.form-width .field-textarea { padding-block: 0.625rem; }

/* In the sticky side column the label track is narrower, so give module names
   room rather than letting every row wrap to two lines. */
.board-side .bar-row { grid-template-columns: minmax(8rem, auto) minmax(0, 1fr) auto; }

/* ---- Detail: sample innovation content ---------------------------------- */
/* Metrics are large plain numerals with a short caption, separated by
   hairlines, never boxes (05-components.md). The Detail view is labelled
   sample content, so these figures are not presented as fact. */
.metrics { list-style: none; display: grid; gap: var(--space-5); margin-top: var(--space-5); }
@media (min-width: 640px) { .metrics { grid-template-columns: repeat(3, 1fr); gap: var(--space-6); } }
.metrics li { border-top: 2px solid var(--color-border-strong); padding-top: var(--space-3); }
.metric-value {
  display: block;
  font-size: var(--text-h2); font-weight: var(--weight-semibold);
  line-height: 1.05; letter-spacing: var(--tracking-h2);
  font-variant-numeric: tabular-nums;
}
.metric-label {
  display: block; margin-top: var(--space-2);
  font-size: var(--text-small); color: var(--color-text-muted);
}

.plain-list { list-style: none; margin-top: var(--space-4); border-top: var(--border-width) solid var(--color-border); }
.plain-list li {
  padding-block: var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
  font-size: var(--text-small);
}

.steps-list { margin-top: var(--space-4); padding-left: 0; list-style: none; counter-reset: step; }
.steps-list li {
  counter-increment: step;
  display: grid; grid-template-columns: 2rem 1fr; gap: var(--space-3);
  padding-block: var(--space-4);
  border-bottom: var(--border-width) solid var(--color-border);
  font-size: var(--text-small);
}
.steps-list li:first-child { border-top: var(--border-width) solid var(--color-border); }
.steps-list li::before {
  content: counter(step);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--color-accent);
}

/* With no data the module-bars column is hidden, so the two-column board would
   leave the panel stranded in the left half. Collapse to one column then. */
@media (min-width: 1024px) {
  .board-grid:has(.board-side[hidden]) { grid-template-columns: minmax(0, 1fr); }
}
