/*
 * Rails product layer. Layout rules for server-rendered product pages.
 * Tokens and controls are shared with the public site and React player.
 */

html {
  overflow-y: scroll;
  scroll-padding-top: 5.25rem;
}

.product-page {
  min-height: 100dvh;
  padding: 0;
  background-color: var(--color-paper);
  background-image: none;
}

.product-page h1 {
  max-width: 19ch;
  font-size: var(--text-display);
  line-height: 1.07;
}

.product-page h2 { letter-spacing: -0.015em; }
.product-page :focus-visible { outline-color: var(--color-focus); }

.app-shell {
  width: min(calc(100% - 2 * var(--page-gutter)), var(--shell-width));
  margin-inline: auto;
}

.app-shell {
  min-height: calc(100dvh - 13rem);
  padding-block: clamp(2.75rem, 7vw, 6rem) clamp(5rem, 9vw, 8rem);
}

.app-shell:focus { outline: 0; }

.flash-stack { inset-block-start: 5rem; }
.flash { border-radius: var(--radius-medium); }

.page-head,
.lesson-head {
  gap: 1.75rem;
  padding-block: 0 clamp(3.5rem, 8vw, 6rem);
}

.page-head--workbench { padding-block-end: clamp(2.75rem, 6vw, 4.5rem); }

.page-head > div > p:last-child,
.lesson-head__artist,
.auth-intro p:last-child {
  max-width: 58ch;
  line-height: 1.65;
}

.page-actions {
  justify-content: flex-start;
  gap: 0.5rem;
}

.lesson-actions form,
.asset-list__actions form,
.page-actions form { margin: 0; }

.stat-rail {
  gap: 0;
  background: transparent;
}

.stat-rail > div + div { border-inline-start: 1px solid var(--color-rule); }

.stat-rail dd {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.workbench-section,
.prose-section { padding-block: clamp(2.75rem, 6vw, 4.75rem); }

.workbench-section + .workbench-section,
.workbench-section + .prose-section,
.prose-section + .workbench-section { border-block-start: 1px solid var(--color-rule); }

.section-head { margin-block-end: 1.5rem; }

.lesson-entry__raga {
  color: var(--color-accent);
  font-weight: 700;
}

.lesson-entry__facts,
.media-entry dl {
  padding-block-start: 1rem;
  border-block-start: 1px solid var(--color-rule);
}

.lesson-entry,
.media-entry {
  transition-property: background-color, box-shadow;
  transition-duration: var(--dur-short);
  transition-timing-function: var(--ease-out);
}

.lesson-entry:focus-within,
.media-entry:focus-within {
  background: var(--color-paper-3);
  box-shadow: inset 0 -2px 0 var(--color-accent);
}

.editor-form {
  max-width: 64rem;
  gap: 1.5rem;
}

.editor-form > .button { justify-self: start; }

.field-grid { gap: 1rem 1.25rem; }

.inline-editor,
.stem-pack-form { grid-template-columns: minmax(0, 1fr); }

.form-section[open] summary {
  padding-block-end: 0.75rem;
  border-block-end: 1px solid var(--color-rule);
}

.ownership-note {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.35rem;
  border-inline-start: 3px solid var(--color-accent);
}

.ownership-note strong { color: var(--color-ink); }

.activity-list article,
.activity-list--full article { grid-template-columns: minmax(0, 1fr); }

.activity-list article strong a,
.asset-list article strong a {
  text-decoration-color: transparent;
  transition-property: color, text-decoration-color;
  transition-duration: var(--dur-short);
  transition-timing-function: var(--ease-out);
}

.asset-list .asset-list__actions { justify-content: flex-start; }

.leader-list__rank {
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
}

.phrase-row,
.phrase-row--new { grid-template-columns: minmax(0, 1fr); }

.publish-panel > form {
  display: grid;
  flex: 1 1 28rem;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

.auth-shell {
  min-height: min(44rem, calc(100dvh - 13rem));
  align-content: center;
  grid-template-columns: minmax(0, 1fr);
}

.auth-intro h1 { max-width: 13ch; }

.auth-links {
  padding-block-start: 1rem;
  border-block-start: 1px solid var(--color-rule);
}

.auth-links a {
  color: var(--color-muted);
  font-weight: 600;
}

@media (hover: hover) and (pointer: fine) {

  .lesson-entry:hover,
  .media-entry:hover {
    background: var(--color-paper-3);
    box-shadow: inset 0 -2px 0 var(--color-accent);
  }

  .activity-list article strong a:hover,
  .asset-list article strong a:hover {
    color: var(--color-focus);
    text-decoration-color: var(--color-accent);
  }
}

@media (min-width: 40rem) {

  .page-actions { justify-content: flex-end; }

  .ownership-note {
    grid-template-columns: minmax(10rem, 0.28fr) minmax(0, 1fr);
    gap: 1.5rem;
  }
}

@media (min-width: 48rem) {
  .activity-list:not(.activity-list--full) article {
    grid-template-columns: minmax(12rem, 2fr) repeat(3, minmax(6rem, 1fr));
    align-items: center;
  }

  .auth-shell {
    grid-template-columns: minmax(0, 0.8fr) minmax(20rem, 1.2fr);
  }
}

@media (min-width: 56rem) {

  .activity-list--full article {
    grid-template-columns: minmax(12rem, 2fr) minmax(13rem, 1.35fr) repeat(4, minmax(5.5rem, 0.75fr));
    align-items: center;
  }

  .phrase-row {
    grid-template-columns: minmax(5rem, 0.5fr) minmax(9rem, 1.5fr) repeat(3, minmax(6rem, 1fr)) auto;
  }

  .phrase-row--new {
    grid-template-columns: minmax(9rem, 1.5fr) repeat(3, minmax(6rem, 1fr)) auto;
  }

  .publish-panel > form {
    grid-template-columns: repeat(2, minmax(10rem, 1fr)) auto;
    align-items: end;
  }

  .inline-editor { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
  .inline-editor.editor-invite { grid-template-columns: minmax(0, 1fr) auto; }
  .stem-pack-form { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }

}

@media (max-width: 39.999rem) {
  .app-shell { width: min(calc(100% - 3rem), var(--shell-width)); }

  .product-page h1 { font-size: clamp(2.2rem, 12vw, 3.3rem); }

  .page-actions,
  .lesson-actions,
  .form-actions { align-items: stretch; }

  .page-actions .button,
  .lesson-actions .button,
  .form-actions .button { flex: 1 1 auto; }

  .stat-rail > div:nth-child(odd) { border-inline-start: 0; }
  .stat-rail > div:nth-child(n + 3) { border-block-start: 1px solid var(--color-rule); }
  .asset-list article { display: grid; }

  .lesson-entry__facts,
  .media-entry dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .lesson-entry__facts > div:last-child,
  .media-entry dl > div:last-child { grid-column: 1 / -1; }

  .publish-checklist li {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.35rem;
  }

  .danger-zone .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .lesson-entry,
  .media-entry { transition-duration: 0s; }
}

/* Product surfaces share the homepage's quiet canvas and generous hierarchy. */
.product-page :is(h1, h2) { font-weight: 650; letter-spacing: -0.04em; }
.product-page h3 { font-weight: 600; }
.product-page .kicker { font-weight: 500; color: var(--color-accent); letter-spacing: 0; }
.product-page .auth-panel { padding: clamp(1.5rem, 4vw, 3rem); border: 1px solid var(--color-rule); border-radius: var(--radius-large); background: var(--color-glass); box-shadow: var(--shadow-surface); backdrop-filter: blur(16px); }
.product-page .auth-panel h2 { font: 600 15px/1.4 var(--font-body); letter-spacing: 0; }
.product-page .lesson-grid, .product-page .media-grid { gap: 1.5rem; background: transparent; border: 0; }
.product-page .lesson-entry, .product-page .media-entry { border: 0; border-radius: var(--radius-large); box-shadow: var(--shadow-surface); }
.product-page .lesson-entry__main, .product-page .media-entry__main { padding: 2rem; }
.product-page .empty-state { border-radius: var(--radius-large); background: var(--color-surface-raised); border: 0; }
/* The card shares a quiet button's fill, so quiet buttons on it take the outline button's fill and border. Hover keeps the quiet hover color, because the outline hover color matches the card. */
.product-page .empty-state .button--quiet { --button-background: var(--color-surface); --button-border: var(--color-rule-strong); }
/* Two buttons on one line are separated only by a space; an end margin keeps them apart without indenting a wrapped button. */
.product-page .empty-state .button:has(+ .button) { margin-inline-end: var(--space-xs); }
/* A shared track's playlist form: the drop-down and its Move or Add button share a row when there is room. Create new playlist… (value "new", PlaylistItemsController::NEW_PLAYLIST) swaps that button for a name field and Save on the next row. */
.playlist-save-form { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-md); margin-block-start: var(--space-lg); }
.playlist-save-form .field { flex: 1 1 16rem; max-width: 24rem; }
.playlist-save-form .button { margin-block-start: 0; }
.playlist-save-form__existing { display: flex; }
.playlist-save-form__new { display: none; flex: 1 1 100%; flex-wrap: wrap; align-items: end; gap: var(--space-md); }
.playlist-save-form:has(option[value="new"]:checked) .playlist-save-form__new { display: flex; }
.playlist-save-form:has(option[value="new"]:checked) .playlist-save-form__existing { display: none; }
/* The group that appears fades in; the one that goes hides at once. The wrappers carry the transition so the buttons keep their own. The site-wide reduced-motion rule turns it off. */
.playlist-save-form :is(.playlist-save-form__new, .playlist-save-form__existing) { transition: opacity var(--motion-open) var(--motion-ease), translate var(--motion-open) var(--motion-ease); }
/* Only a choice in the form animates: nothing in it has focus while the page loads. */
@starting-style { .playlist-save-form:focus-within :is(.playlist-save-form__new, .playlist-save-form__existing) { opacity: 0; translate: 0 0.5rem; } }

.ai-processing-icon { display: inline-block; width: 1.1em; height: 1.1em; flex-shrink: 0; vertical-align: -.15em; color: var(--color-focus); }
