/*
 * LP Train visual system
 *
 * This stylesheet intentionally contains presentation only. The prototype's
 * route, state, persistence, and interaction code remain in the HTML file.
 */

:root,
[data-theme="light"] {
  --lp-page-gutter: 24px;
  --lp-section-gap: 32px;
  --lp-stack-gap: 12px;
  --lp-control-height: 48px;
  --lp-icon-control: 44px;
  --lp-radius-control: 8px;
  --lp-radius-container: 12px;
  --lp-page-title: 28px;
  --lp-section-title: 20px;
  --lp-body: 16px;
  --lp-label: 12px;
  --radius-xl: 12px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 8px;
  --control-h: var(--lp-control-height);
  --surface-subtle: #f5f6f6;
  --surface-hover: #eef1f1;
  --line: #d8dede;
  --line-strong: #aeb8ba;
  --muted: #555d60;
  --faint: #7a8386;
  --focus-ring: rgba(5, 6, 7, 0.18);
}

[data-theme="dark"] {
  --surface: #080909;
  --surface-subtle: #101212;
  --surface-hover: #171a1a;
  --surface-elevated: #0d0f0f;
  --line: #353d3f;
  --line-strong: #697477;
  --muted: #c2c9cb;
  --faint: #969fa2;
  --focus-ring: rgba(255, 255, 255, 0.24);
}

html,
body,
#app {
  min-width: 0;
  background: var(--bg) !important;
}

body,
button,
input,
textarea,
select {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0 !important;
}

body {
  padding: 0 !important;
  font-size: var(--lp-body);
  line-height: 1.45;
}

.app-shell,
.app-shell.coach-shell {
  width: 100vw !important;
  max-width: 652px !important;
  min-width: 0 !important;
  margin-inline: auto !important;
}

.tablet-frame,
.coach-frame,
.app-shell.coach-shell .tablet-frame {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.screen,
.coach-screen {
  min-width: 0;
  padding: 32px var(--lp-page-gutter) calc(48px + env(safe-area-inset-bottom)) !important;
}

.screen-scroll {
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

/* Restrained, consistent type hierarchy. */
.coach-title,
.client-home-screen .coach-title,
.tracking-athlete-name,
.builder-title,
.top-title h1,
.workout-title-input,
.coach-title-input {
  max-width: 100%;
  margin: 0;
  font-size: var(--lp-page-title) !important;
  line-height: 1.12 !important;
  font-weight: 800 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  overflow-wrap: anywhere;
}

.coach-panel h2,
.panel-head h2,
.section-head h2,
.tracker-title,
.workout-section-title-input,
.workout-section-title-static,
.client-workout-day-title,
.client-readonly-note h2 {
  font-size: var(--lp-section-title) !important;
  line-height: 1.2 !important;
  font-weight: 780 !important;
  letter-spacing: 0 !important;
}

.coach-kicker,
.detail-label,
.mobile-field-label,
.macrocycle-label,
.workout-builder-head,
.workout-section-tracking-head,
.label-col,
.field-group > label {
  font-size: var(--lp-label) !important;
  line-height: 1.2 !important;
  font-weight: 760 !important;
  letter-spacing: 0 !important;
}

.item-meta,
.workout-item-dates,
.status-note,
.submitted-note,
.tracking-workout-meta {
  color: var(--muted) !important;
  font-weight: 650 !important;
}

/* Controls share one geometry and do not jump on hover. */
button,
.field,
.search-input,
.metric-input,
.cell-input,
.note-title-input,
.macrocycle-input,
.macrocycle-select,
.assessment-result-input {
  border-radius: var(--lp-radius-control) !important;
}

button:not(:disabled):not(.entity-open):not(.macrocycle-focus-hotzone):hover,
button:not(:disabled):active {
  transform: none !important;
}

button:not(:disabled):not(.entity-open):not(.macrocycle-focus-hotzone):hover {
  box-shadow: none !important;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--text) 72%, transparent) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 4px var(--focus-ring) !important;
}

.field,
.search-input,
.note-title-input,
.assessment-result-input {
  min-height: var(--lp-control-height) !important;
  padding-inline: 14px !important;
  font-size: 16px !important;
}

.primary-button,
.solid-button,
.quiet-button,
.danger-button,
.mode-button {
  min-height: var(--lp-control-height) !important;
  padding: 0 16px !important;
  font-size: 13px !important;
  font-weight: 780 !important;
}

.icon-button,
.theme-icon,
.signout-button,
.builder-icon-button,
.edit-button,
.plus-button,
.minus-button,
.row-button,
.row-spacer,
.done-check,
.save-check,
.section-mini-button,
.workout-info-mini-button,
.remove-test-button {
  width: var(--lp-icon-control) !important;
  min-width: var(--lp-icon-control) !important;
  height: var(--lp-icon-control) !important;
  min-height: var(--lp-icon-control) !important;
  border-radius: var(--lp-radius-control) !important;
}

.icon-svg,
.builder-icon-button svg,
.edit-button svg,
.row-button svg,
.theme-icon svg,
.signout-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.25 !important;
}

/* Stable page header rail: back, title, and actions share the same gutters. */
.coach-top,
.coach-top.has-back,
.coach-home-screen .coach-top {
  width: 100%;
  display: grid !important;
  grid-template-columns: var(--lp-icon-control) minmax(0, 1fr) auto !important;
  grid-template-areas:
    "back spacer actions"
    "title title title" !important;
  align-items: center !important;
  gap: 12px !important;
  margin: 0 0 32px !important;
}

.coach-heading,
.coach-top.has-back .coach-heading {
  display: contents !important;
}

.coach-heading > .back-button,
.coach-top.has-back .back-button {
  grid-area: back;
  justify-self: start;
  margin: 0 !important;
}

.coach-heading > div {
  grid-area: title;
  justify-self: center;
  width: min(100%, 560px);
  text-align: center;
  min-width: 0;
}

.coach-heading h1,
.coach-heading .coach-title,
.coach-heading .page-title {
  max-width: 100% !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.coach-actions,
.coach-home-screen .coach-actions {
  grid-area: actions;
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px !important;
  flex-wrap: nowrap !important;
}

.coach-heading .coach-kicker {
  margin: 0 0 4px;
  text-align: center;
}

/* Coach home is grouped by rhythm and dividers, not nested cards. */
.coach-home-stack {
  width: 100% !important;
  display: grid;
  gap: 0 !important;
  margin-inline: auto;
}

.coach-home-panel {
  min-height: 0 !important;
  padding: 0 0 24px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
}

.coach-home-panel + .coach-home-panel {
  padding-top: 24px !important;
  border-top: 1px solid var(--line) !important;
}

.coach-home-panel .panel-head {
  padding: 0 0 12px !important;
  gap: 10px !important;
  border: 0 !important;
}

.coach-home-panel .panel-head h2 {
  font-size: var(--lp-section-title) !important;
}

.coach-home-panel .solid-button {
  min-height: 44px !important;
  background: var(--surface-subtle) !important;
  border-color: var(--line) !important;
}

.coach-home-panel .search-row,
.coach-home-panel .panel-head > .search-row {
  margin: 0 !important;
}

.coach-home-panel .search-input,
.coach-home-panel .panel-head > .search-row .search-input {
  min-height: 44px !important;
  padding-left: 42px !important;
  background: var(--surface) !important;
  font-size: 16px !important;
}

.coach-home-panel .coach-list {
  border-radius: var(--lp-radius-container) !important;
  box-shadow: 0 16px 36px rgba(5, 6, 7, 0.14) !important;
}

/* Repeated navigation and library rows use one compact list language. */
.profile-nav,
.library-list,
.assessment-list,
.notes-grid,
.workout-library-list,
.membership-list,
.roster-list {
  gap: var(--lp-stack-gap) !important;
}

/* The workout library already receives spacing from the screen stack. Avoid
 * compounding legacy header, list, and section margins into a large dead zone. */
.library-top:has(+ .workout-library-list) {
  margin-bottom: 0 !important;
}

.library-top:has(+ .workout-library-list) .coach-top {
  margin-bottom: 0 !important;
}

.coach-screen > .workout-library-list {
  margin-top: 0 !important;
}

.workout-library-list > .workout-section-toggle:first-child {
  margin-top: 0 !important;
}

.workout-section-toggle,
.assessment-section-toggle {
  min-height: 44px !important;
  padding-block: 8px !important;
}

.profile-button,
.library-item,
.program-block-card,
.workout-current-item,
.workout-dropdown-item,
.assessment-scheduled-row,
.assessment-result-row,
.member-row,
.roster-person,
.workout-week-workout-title {
  min-height: 56px !important;
  padding: 14px 16px !important;
  border-radius: var(--lp-radius-container) !important;
  box-shadow: none !important;
}

.profile-button,
.client-home-screen .profile-button {
  font-size: 16px !important;
  font-weight: 740 !important;
}

.library-item .item-title,
.workout-current-item .item-title,
.workout-dropdown-item .item-title {
  font-size: 16px !important;
  line-height: 1.2 !important;
  font-weight: 760 !important;
}

.client-home-screen .profile-nav {
  margin-top: 48px !important;
}

/* Forms retain visible labels and use predictable vertical rhythm. */
.edit-form,
.creation-form,
.library-add-form,
.assessment-add-form,
.assessment-edit-form,
.notes-editor-form,
.macroplan-add-form {
  gap: 16px !important;
}

.field-group {
  gap: 8px !important;
}

.add-person-row {
  gap: 8px !important;
}

.note-block,
.client-readonly-note,
.tracker-section,
.workout-section-shell,
.workout-builder-table,
.macrocycle-shell,
.workout-calendar-panel {
  border-radius: var(--lp-radius-container) !important;
  box-shadow: none !important;
}

.note-block {
  gap: 8px !important;
}

.note-copy,
.workout-note-area,
.macrocycle-textarea {
  border-radius: var(--lp-radius-container) !important;
  line-height: 1.45 !important;
}

/* Workout surfaces stay dense and readable without changing their grid logic. */
.workout-builder-shell {
  gap: 24px !important;
}

.workout-builder-canvas,
.workout-day-body {
  gap: 16px !important;
}

.workout-day-head,
.workout-section-tracking-head {
  margin-bottom: 8px !important;
}

.workout-builder-row,
.tracker-row {
  align-items: center !important;
}

.workout-builder-row:not(.workout-builder-head) {
  min-height: 52px;
}

.cell-input,
.metric-input {
  min-height: 40px !important;
  font-size: 16px !important;
}

.workout-builder-day-tabs,
.program-block-strip,
.client-workout-tabs {
  gap: 8px !important;
  scrollbar-width: thin;
}

.workout-builder-day-tabs button,
.program-block-button,
.client-workout-tabs button {
  min-height: 44px !important;
  padding-inline: 14px !important;
}

/* Macroplan remains horizontally scrollable; row labels stay visible. */
.macrocycle-scroll {
  width: 100%;
  overflow: auto !important;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  border-inline: 1px solid var(--line);
}

.macrocycle-grid {
  isolation: isolate;
}

.macrocycle-label,
.macrocycle-vertical-label {
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--surface-subtle) !important;
  border-right-color: var(--line-strong) !important;
}

.macrocycle-cell,
.macrocycle-date-cell,
.macrocycle-label {
  border-color: var(--line) !important;
}

/* Dialogs are focused, contained, and usable at phone height. */
.modal-layer {
  padding: 16px !important;
}

.info-popover {
  width: min(100%, 520px) !important;
  max-height: calc(100dvh - 32px) !important;
  padding: 24px !important;
  border-radius: var(--lp-radius-container) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

.modal-head {
  margin-bottom: 16px !important;
}

.modal-copy {
  line-height: 1.5 !important;
}

.modal-actions {
  gap: 8px !important;
  padding-top: 16px !important;
}

/* Authentication is the one intentionally centered flow. */
.app-shell:not(.coach-shell) .login-screen {
  justify-content: center !important;
  align-items: center !important;
  padding: 24px !important;
}

.app-shell:not(.coach-shell) .login-stack {
  width: calc(100vw - 48px) !important;
  max-width: 440px !important;
  min-width: 0 !important;
  gap: 14px !important;
  padding: 32px !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--lp-radius-container) !important;
  background: var(--surface) !important;
  box-shadow: 0 20px 48px rgba(5, 6, 7, 0.10) !important;
}

[data-theme="dark"] .app-shell:not(.coach-shell) .login-stack {
  background: #080a0a !important;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.34) !important;
}

.app-shell:not(.coach-shell) .login-stack .brand {
  margin: 0 0 20px !important;
}

.app-shell:not(.coach-shell) .login-logo-picture.login-logo {
  width: min(100%, 340px) !important;
  height: 124px !important;
  margin-inline: auto !important;
}

.segmented {
  min-height: var(--lp-control-height) !important;
  border-radius: var(--lp-radius-control) !important;
}

.segmented button {
  min-height: 46px !important;
}

/* Dark mode uses visible but restrained boundaries. */
[data-theme="dark"] .coach-home-panel + .coach-home-panel,
[data-theme="dark"] .profile-button,
[data-theme="dark"] .library-item,
[data-theme="dark"] .program-block-card,
[data-theme="dark"] .workout-current-item,
[data-theme="dark"] .workout-dropdown-item,
[data-theme="dark"] .assessment-scheduled-row,
[data-theme="dark"] .assessment-result-row,
[data-theme="dark"] .note-block,
[data-theme="dark"] .client-readonly-note,
[data-theme="dark"] .tracker-section,
[data-theme="dark"] .workout-builder-table,
[data-theme="dark"] .workout-section-shell,
[data-theme="dark"] .macrocycle-shell {
  border-color: var(--line) !important;
}

@media (max-width: 640px) {
  :root,
  [data-theme="light"],
  [data-theme="dark"] {
    --lp-page-gutter: 16px;
    --lp-section-gap: 24px;
    --lp-page-title: 24px;
    --lp-section-title: 18px;
  }

  .screen,
  .coach-screen {
    padding-top: max(20px, env(safe-area-inset-top)) !important;
    padding-left: max(var(--lp-page-gutter), env(safe-area-inset-left)) !important;
    padding-right: max(var(--lp-page-gutter), env(safe-area-inset-right)) !important;
  }

  .coach-top,
  .coach-top.has-back,
  .coach-home-screen .coach-top {
    margin-bottom: 24px !important;
  }

  .coach-actions,
  .coach-home-screen .coach-actions {
    max-width: calc(100vw - 88px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .coach-heading h1,
  .coach-heading .coach-title,
  .coach-heading .page-title {
    font-size: var(--lp-page-title) !important;
    line-height: 1.15 !important;
  }

  .coach-actions::-webkit-scrollbar,
  .coach-home-screen .coach-actions::-webkit-scrollbar {
    display: none;
  }

  .coach-home-panel {
    padding-bottom: 20px !important;
  }

  .coach-home-panel + .coach-home-panel {
    padding-top: 20px !important;
  }

  .profile-nav,
  .library-list,
  .assessment-list,
  .notes-grid,
  .workout-library-list {
    width: 100% !important;
  }

  .profile-button,
  .library-item,
  .program-block-card,
  .workout-current-item,
  .workout-dropdown-item,
  .assessment-scheduled-row,
  .assessment-result-row,
  .workout-week-workout-title {
    padding: 12px 14px !important;
  }

  .workout-item-dates,
  .item-meta {
    font-size: 12px !important;
    white-space: normal !important;
    text-align: right;
  }

  .workout-builder-shell {
    gap: 20px !important;
  }

  .workout-builder-shell .workout-builder-canvas {
    padding-inline: 0 !important;
  }

  .workout-section-actions,
  .workout-section-edit-controls,
  .workout-section-move-controls {
    gap: 6px !important;
  }

  .workout-section-title-input,
  .workout-section-title-static {
    font-size: var(--lp-section-title) !important;
  }

  .cell-input,
  .metric-input {
    font-size: 16px !important;
  }

  .modal-layer {
    align-items: flex-end !important;
    padding: 12px !important;
  }

  .info-popover {
    width: 100% !important;
    max-height: calc(100dvh - 24px) !important;
    padding: 20px !important;
  }

  .app-shell:not(.coach-shell) .login-screen {
    padding: 16px !important;
  }

  .app-shell:not(.coach-shell) .login-stack {
    width: calc(100vw - 32px) !important;
    max-width: 440px !important;
    padding: 24px 18px !important;
  }

  .app-shell:not(.coach-shell) .login-logo-picture.login-logo {
    width: min(100%, 300px) !important;
    height: 108px !important;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  :root,
  [data-theme="light"],
  [data-theme="dark"] {
    --lp-page-gutter: 24px;
  }

  .screen,
  .coach-screen {
    padding-top: 32px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  .tablet-frame,
  .coach-frame,
  .app-shell.coach-shell .tablet-frame {
    border: 0 !important;
    box-shadow: none !important;
  }
}
