/* Shared visual foundation for the GCA Crew Portal. Feature-specific layouts
   remain in site.css and can opt into these semantic tokens. */
:root {
  --ds-space-1: 0.25rem;
  --ds-space-2: 0.5rem;
  --ds-space-3: 0.75rem;
  --ds-space-4: 1rem;
  --ds-space-6: 1.5rem;
  --ds-space-8: 2rem;

  --ds-type-caption: 0.75rem;
  --ds-type-meta: 0.82rem;
  --ds-type-body: 0.9rem;
  --ds-type-lead: 1rem;
  --ds-type-section: 1.12rem;
  --ds-type-page-title: 1.55rem;

  --ds-radius-compact: 3px;
  --ds-radius-control: 4px;
  --ds-radius-panel: 6px;
  --ds-layout-max: 1360px;
  --ds-control-height: 2.65rem;
  --ds-touch-height: 44px;

  --ds-canvas: var(--paper);
  --ds-surface: var(--panel);
  --ds-surface-subtle: var(--surface-subtle);
  --ds-text: var(--ink);
  --ds-text-muted: var(--muted);
  --ds-border: var(--line);
  --ds-border-strong: var(--line-strong);
  --ds-focus: var(--focus);
  --ds-primary: var(--cedar);
  --ds-primary-bg: #82dabe;
  --ds-primary-ink: #06261e;
  --ds-primary-hover: #9ce8cd;
  --ds-primary-pressed: #67c8a6;
  --ds-secondary-bg: var(--panel);
  --ds-secondary-ink: var(--cedar);
  --ds-shadow-panel: var(--shadow);
  --ds-shadow-popover: 0 12px 32px rgb(0 0 0 / 24%);
}

:root[data-display-theme="light"] {
  --ds-primary-bg: #1f5a40;
  --ds-primary-ink: #ffffff;
  --ds-primary-hover: #174a34;
  --ds-primary-pressed: #123d2b;
  --ds-secondary-bg: #ffffff;
  --ds-secondary-ink: #1f5a40;
  --ds-shadow-popover: 0 12px 32px rgb(20 30 24 / 18%);
}

html {
  scroll-padding-top: calc(var(--header-offset, 3.5rem) + var(--ds-space-4));
}

body {
  color: var(--ds-text);
  background: var(--ds-canvas);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--ds-type-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page {
  width: min(var(--ds-layout-max), calc(100% - 2rem));
  margin: var(--ds-space-4) auto var(--ds-space-8);
}

.panel {
  padding: clamp(1rem, 2vw, 1.5rem);
  border-color: var(--ds-border);
  border-radius: var(--ds-radius-panel);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-panel);
}

.panel h1,
.page-header h1 {
  font-size: var(--ds-type-page-title);
  line-height: 1.2;
  text-wrap: balance;
}

.section-header h2,
.dashboard-section h2 {
  font-size: var(--ds-type-section);
  line-height: 1.3;
  text-wrap: balance;
}

.eyebrow {
  color: var(--ds-text-muted);
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: uppercase;
}

.meta,
.privacy-note,
.help-text,
.stacked-form .helptext {
  color: var(--ds-text-muted);
}

.page-header {
  min-height: 0;
  align-items: center;
  gap: var(--ds-space-4);
  margin-bottom: var(--ds-space-4);
  padding-bottom: var(--ds-space-3);
}

.page-header-copy {
  gap: var(--ds-space-1);
}

.page-header-copy h1,
.page-header-copy p {
  margin-block: 0;
}

.page-header-copy > .meta {
  max-width: 68ch;
  font-size: var(--ds-type-meta);
}

.page-header-actions,
.action-bar,
.actions {
  gap: var(--ds-space-2);
}

.button {
  min-height: 2.5rem;
  padding: 0.52rem 0.82rem;
  border: 1px solid var(--ds-primary-bg);
  border-radius: var(--ds-radius-control);
  background: var(--ds-primary-bg);
  color: var(--ds-primary-ink);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.25;
  box-shadow: none;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button:hover {
  border-color: var(--ds-primary-hover);
  background: var(--ds-primary-hover);
  color: var(--ds-primary-ink);
}

.button:active {
  border-color: var(--ds-primary-pressed);
  background: var(--ds-primary-pressed);
}

.button.secondary {
  border-color: var(--ds-border-strong);
  background: var(--ds-secondary-bg);
  color: var(--ds-secondary-ink);
}

.button.secondary:hover {
  border-color: var(--ds-primary);
  background: var(--ds-surface-subtle);
  color: var(--ds-secondary-ink);
}

.dashboard-scene .button:not(.secondary):not(.danger):not(.danger-button) {
  border-color: var(--ds-primary-bg);
  background: var(--ds-primary-bg);
  color: var(--ds-primary-ink);
  box-shadow: none;
}

.dashboard-scene .button:not(.secondary):not(.danger):not(.danger-button):hover {
  border-color: var(--ds-primary-hover);
  background: var(--ds-primary-hover);
  color: var(--ds-primary-ink);
}

.dashboard-scene .dashboard-primary-actions .button.secondary {
  border-color: var(--ds-border-strong);
  background: var(--ds-secondary-bg);
  color: var(--ds-secondary-ink);
  box-shadow: none;
}

.dashboard-scene .dashboard-primary-actions .button.secondary:hover {
  border-color: var(--ds-primary);
  background: var(--ds-surface-subtle);
  color: var(--ds-secondary-ink);
}

.button.danger,
.danger-button {
  border-color: var(--danger-border);
  background: var(--danger-surface);
  color: var(--danger-text);
}

.button.danger:hover,
.danger-button:hover {
  border-color: var(--danger-border);
  background: color-mix(in srgb, var(--danger-surface) 82%, var(--danger-text));
  color: var(--danger-text);
}

.button:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--ds-focus);
  outline-offset: 2px;
}

.stacked-form {
  gap: var(--ds-space-4);
}

.stacked-form p {
  gap: var(--ds-space-1);
  margin: 0;
}

.stacked-form label,
.filter-bar label,
.search-form label,
.form-field > label,
.access-fieldset legend {
  color: var(--ds-text);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.4;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  min-height: var(--ds-control-height);
  padding: 0.52rem 0.68rem;
  border-color: var(--ds-border-strong);
  border-radius: var(--ds-radius-control);
  background-color: var(--ds-surface);
  color: var(--ds-text);
  font: inherit;
  line-height: 1.4;
}

input:not([type="checkbox"]):not([type="radio"]):hover,
select:hover,
textarea:hover {
  border-color: var(--ds-primary);
}

input::placeholder,
textarea::placeholder {
  color: var(--ds-text-muted);
  opacity: 0.9;
}

select option {
  background: var(--ds-surface);
  color: var(--ds-text);
}

.filter-bar,
.search-form,
.library-search {
  gap: var(--ds-space-2);
  padding: var(--ds-space-3);
  border-color: var(--ds-border);
  border-radius: var(--ds-radius-panel);
  background: var(--ds-surface-subtle);
  box-shadow: none;
}

.data-table th {
  background: var(--ds-surface-subtle);
  color: var(--ds-text-muted);
  font-size: var(--ds-type-caption);
}

.data-table th,
.data-table td {
  padding: 0.62rem 0.68rem;
}

.table-wrap,
.resource-item,
.choice,
.empty-state,
.result-count {
  border-color: var(--ds-border);
  border-radius: var(--ds-radius-control);
}

.empty-state {
  background: var(--ds-surface-subtle);
  color: var(--ds-text-muted);
}

.status-badge,
.access-label,
.readiness-badge,
.roster-count {
  border-radius: var(--ds-radius-compact);
  font-weight: 700;
}

.nav-link,
.nav-menu summary {
  min-height: 2.5rem;
  align-content: center;
  transition: background-color 140ms ease, color 140ms ease;
}

.nav-link:focus-visible,
.nav-menu summary:focus-visible,
.nav-toggle:focus-visible {
  outline-color: var(--ds-focus);
}

.nav-toggle {
  min-height: var(--ds-touch-height);
}

.nav-menu-panel {
  border-color: var(--ds-border);
  border-radius: var(--ds-radius-control);
  box-shadow: var(--ds-shadow-popover);
}

.nav-menu-panel a,
.nav-menu-panel button {
  min-height: 2.5rem;
  border-radius: var(--ds-radius-compact);
}

@media (max-width: 720px) {
  body {
    font-size: 1rem;
  }

  .page {
    width: calc(100% - 1rem);
    margin: var(--ds-space-2) auto var(--ds-space-6);
  }

  .panel {
    padding: 0.9rem 0.8rem;
    border-right: 1px solid var(--ds-border);
    border-left: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-panel);
    box-shadow: var(--ds-shadow-panel);
  }

  .page-header {
    align-items: flex-start;
    gap: var(--ds-space-3);
  }

  .page-header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .button,
  .nav-toggle,
  .site-nav > .nav-link,
  .site-nav .nav-menu summary,
  .nav-menu-panel a,
  .nav-menu-panel button {
    min-height: var(--ds-touch-height);
  }

  .dashboard-scene .dashboard-primary-actions .button {
    min-height: var(--ds-touch-height);
  }

  .nav-menu-panel a,
  .nav-menu-panel button {
    padding: 0.65rem 0.75rem;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-height: var(--ds-touch-height);
    font-size: 1rem;
  }

  .filter-bar,
  .search-form,
  .library-search {
    padding: var(--ds-space-2);
  }
}

@media (max-width: 520px) {
  .panel h1,
  .page-header h1 {
    font-size: 1.42rem;
  }

  .section-header > .button,
  .page-header-actions > .button {
    width: 100%;
  }

  .data-table th,
  .data-table td {
    padding: 0.55rem;
  }
}

@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 {
  body {
    color: #111;
    background: #fff;
    font-size: 10pt;
  }

  .page {
    width: auto;
    max-width: none;
    margin: 0;
  }

  .panel {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
}
