/* ==========================================================================
   Electro Tafukt: Modern Solar Editorial Stylesheet
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Raw palette tokens (2 core neutrals + 1 deliberate solar accent) */
  --bg-light: #f6f3ec;
  --bg-dark: #12151b;

  --surface-light: #efeae0;
  --surface-dark: #1a1f28;

  --surface-strong-light: #fffdf9;
  --surface-strong-dark: #212733;

  --ink-light: #181c22;
  --ink-dark: #f4f0e8;

  --ink-muted-light: #4a515c;
  --ink-muted-dark: #b3bbc7;

  --border-light: #cec7b9;
  --border-dark: #2f3747;

  --control-border-light: #7a7365;
  --control-border-dark: #7a8599;

  --accent-light: #9a4106;
  --accent-dark: #f2a33b;

  --accent-hover-light: #7c3304;
  --accent-hover-dark: #f7b95e;

  --accent-ink-light: #fffdf9;
  --accent-ink-dark: #12151b;

  --error-light: #b42318;
  --error-dark: #ff8a80;

  --error-bg-light: #fdf2f2;
  --error-bg-dark: #2d1a1c;

  --success-light: #146c43;
  --success-dark: #6ee7b7;

  --success-bg-light: #edf8f2;
  --success-bg-dark: #132820;

  /* Resolved semantic tokens: light default + fallbacks for browsers without light-dark() */
  --bg: var(--bg-light);
  --surface: var(--surface-light);
  --surface-strong: var(--surface-strong-light);
  --ink: var(--ink-light);
  --ink-muted: var(--ink-muted-light);
  --border: var(--border-light);
  --control-border: var(--control-border-light);
  --accent: var(--accent-light);
  --accent-hover: var(--accent-hover-light);
  --accent-ink: var(--accent-ink-light);
  --error: var(--error-light);
  --error-bg: var(--error-bg-light);
  --success: var(--success-light);
  --success-bg: var(--success-bg-light);

  /* Combined color-scheme state for non-color branches */
  --color-scheme: light;

  /* Typography & rhythm */
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-body: "DM Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --container-max: 1120px;
  --gutter: clamp(1.125rem, 3.5vw, 2.5rem);

  @media (prefers-color-scheme: dark) {
    --color-scheme: dark;
    --bg: var(--bg-dark);
    --surface: var(--surface-dark);
    --surface-strong: var(--surface-strong-dark);
    --ink: var(--ink-dark);
    --ink-muted: var(--ink-muted-dark);
    --border: var(--border-dark);
    --control-border: var(--control-border-dark);
    --accent: var(--accent-dark);
    --accent-hover: var(--accent-hover-dark);
    --accent-ink: var(--accent-ink-dark);
    --error: var(--error-dark);
    --error-bg: var(--error-bg-dark);
    --success: var(--success-dark);
    --success-bg: var(--success-bg-dark);
  }

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
    --color-scheme: dark;
    --bg: var(--bg-dark);
    --surface: var(--surface-dark);
    --surface-strong: var(--surface-strong-dark);
    --ink: var(--ink-dark);
    --ink-muted: var(--ink-muted-dark);
    --border: var(--border-dark);
    --control-border: var(--control-border-dark);
    --accent: var(--accent-dark);
    --accent-hover: var(--accent-hover-dark);
    --accent-ink: var(--accent-ink-dark);
    --error: var(--error-dark);
    --error-bg: var(--error-bg-dark);
    --success: var(--success-dark);
    --success-bg: var(--success-bg-dark);
  }

  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
    --color-scheme: light;
    --bg: var(--bg-light);
    --surface: var(--surface-light);
    --surface-strong: var(--surface-strong-light);
    --ink: var(--ink-light);
    --ink-muted: var(--ink-muted-light);
    --border: var(--border-light);
    --control-border: var(--control-border-light);
    --accent: var(--accent-light);
    --accent-hover: var(--accent-hover-light);
    --accent-ink: var(--accent-ink-light);
    --error: var(--error-light);
    --error-bg: var(--error-bg-light);
    --success: var(--success-light);
    --success-bg: var(--success-bg-light);
  }

  @supports (color: light-dark(white, black)) {
    --bg: light-dark(var(--bg-light), var(--bg-dark));
    --surface: light-dark(var(--surface-light), var(--surface-dark));
    --surface-strong: light-dark(var(--surface-strong-light), var(--surface-strong-dark));
    --ink: light-dark(var(--ink-light), var(--ink-dark));
    --ink-muted: light-dark(var(--ink-muted-light), var(--ink-muted-dark));
    --border: light-dark(var(--border-light), var(--border-dark));
    --control-border: light-dark(var(--control-border-light), var(--control-border-dark));
    --accent: light-dark(var(--accent-light), var(--accent-dark));
    --accent-hover: light-dark(var(--accent-hover-light), var(--accent-hover-dark));
    --accent-ink: light-dark(var(--accent-ink-light), var(--accent-ink-dark));
    --error: light-dark(var(--error-light), var(--error-dark));
    --error-bg: light-dark(var(--error-bg-light), var(--error-bg-dark));
    --success: light-dark(var(--success-light), var(--success-dark));
    --success-bg: light-dark(var(--success-bg-light), var(--success-bg-dark));
  }

  accent-color: var(--accent);
}

/* Base reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background-color: var(--accent);
  color: var(--accent-ink);
}

main {
  flex: 1 0 auto;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* Visually hidden helper for screen readers */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--gutter);
  z-index: 100;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
}

.container {
  width: min(100% - (var(--gutter) * 2), var(--container-max));
  margin-inline: auto;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background-color: var(--bg);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 4.5rem;
  padding-block: 0.625rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 44px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.0625rem, 1.5vw, 1.25rem);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.wordmark-mark {
  flex-shrink: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink-muted);
  transition: color 160ms ease, background-color 160ms ease;
}

.nav-link:hover {
  color: var(--ink);
  background-color: var(--surface);
}

.nav-link-primary {
  color: var(--ink);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-md);
  background-color: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.theme-toggle:hover {
  background-color: var(--surface);
  border-color: var(--ink);
}

.theme-toggle:active {
  background-color: var(--surface);
}

/* Non-color branching for theme toggle icon/label using combined --color-scheme state */
.theme-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-option-to-light {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-option-to-dark {
    display: none;
  }

  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-option-to-light {
    display: inline-flex;
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-option-to-dark {
  display: none;
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-option-to-light {
  display: inline-flex;
}

@container style(--color-scheme: dark) {
  .theme-option-to-dark {
    display: none;
  }

  .theme-option-to-light {
    display: inline-flex;
  }
}

@container style(--color-scheme: light) {
  .theme-option-to-dark {
    display: inline-flex;
  }

  .theme-option-to-light {
    display: none;
  }
}

/* Hero Section */
.hero {
  padding-block: clamp(2.5rem, 6vw, 5.25rem) clamp(2.75rem, 6.5vw, 5rem);
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(2rem, 4.5vw, 4rem);
  align-items: start;
}

.hero-copy {
  min-width: 0;
}

.dateline {
  margin: 0 0 1rem;
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 600;
}

.hero-title {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.125rem, 5.2vw, 3.65rem);
  line-height: 1.07;
  letter-spacing: -0.03em;
  text-wrap: balance;
  max-width: 17ch;
}

.hero-lead {
  margin: 0 0 2rem;
  max-width: 54ch;
  color: var(--ink-muted);
  font-size: clamp(1.03125rem, 1.35vw, 1.15625rem);
  line-height: 1.65;
}

/* Launch Notification Form */
.notify-block {
  max-width: 34rem;
  scroll-margin-top: 1.5rem;
}

.notify-form {
  display: grid;
  gap: 0.75rem;
}

.field-group {
  display: grid;
  gap: 0.375rem;
}

.field-label {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--ink);
}

.field-hint {
  margin: 0 0 0.25rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.625rem;
}

.email-input {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 0.9375rem;
  border: 1.5px solid var(--control-border);
  border-radius: var(--radius-md);
  background-color: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  transition: border-color 160ms ease;
}

.email-input::placeholder {
  color: var(--ink-muted);
  opacity: 0.85;
}

.email-input:hover {
  border-color: var(--ink);
}

.email-input:is(:user-invalid, .user-invalid-fallback) {
  border-color: var(--error);
  background-color: var(--error-bg);
}

.email-input:is(:user-valid, .user-valid-fallback) {
  border-color: var(--success);
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.75rem 1.375rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  background-color: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-body);
  font-size: 0.96875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms ease;
}

.submit-btn:hover:not(:disabled) {
  background-color: var(--accent-hover);
}

.submit-btn:active:not(:disabled) {
  background-color: var(--accent-hover);
}

.submit-btn:disabled {
  opacity: 0.72;
  cursor: wait;
}

.field-error {
  display: none;
  align-items: flex-start;
  gap: 0.45rem;
  margin-top: 0.25rem;
  color: var(--error);
  font-size: 0.875rem;
  font-weight: 500;
}

.field-group:has(.email-input:is(:user-invalid, .user-invalid-fallback)) .field-error {
  display: flex;
}

.inline-icon {
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-status {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0.9375rem 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background-color: var(--surface);
  font-size: 0.9375rem;
}

.form-status[hidden] {
  display: none;
}

.form-status-body {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.form-status.is-success {
  border-color: var(--success);
  background-color: var(--success-bg);
  color: var(--ink);
}

.form-status.is-success .status-icon {
  color: var(--success);
}

.form-status.is-error {
  border-color: var(--error);
  background-color: var(--error-bg);
  color: var(--ink);
}

.form-status.is-error .status-icon {
  color: var(--error);
}

.status-reset-btn {
  align-self: flex-start;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  background-color: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.status-reset-btn:hover {
  background-color: var(--surface);
  border-color: var(--ink);
}

/* Right Hero Plate (Identity Motif) */
.hero-plate {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
  overflow: hidden;
  /* Elevation marker: single subtle lift on the focal visual plate */
  box-shadow: 0 10px 28px -22px rgba(24, 28, 34, 0.35);
}

.plate-artwork {
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border-bottom: 1px solid var(--border);
  background-color: var(--surface-strong);
}

.solar-diagram {
  width: 100%;
  height: auto;
}

.spec-list {
  margin: 0;
  padding: 0;
}

.spec-row {
  display: grid;
  grid-template-columns: minmax(6.5rem, 8.5rem) minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem clamp(1rem, 2.5vw, 1.5rem);
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

.spec-row-link {
  padding-block: 0.375rem;
}

.spec-row:last-child {
  border-bottom: 0;
}

.spec-row dt {
  color: var(--ink-muted);
  font-weight: 500;
}

.spec-row dd {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.inline-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
  transition: color 160ms ease;
}

.inline-link:hover {
  color: var(--accent);
}

/* Catalog Section (Varied Editorial Rhythm) */
.catalog-section {
  padding-block: clamp(2.5rem, 6vw, 4.75rem);
  scroll-margin-top: 1rem;
}

.catalog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.75rem, 4vw, 3.5rem);
}

.section-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 3vw, 2.125rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.section-copy {
  margin: 0;
  max-width: 34ch;
  color: var(--ink-muted);
  font-size: 1rem;
}

.department-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

.department-item {
  min-width: 0;
  padding-top: 1.25rem;
  border-top: 1.5px solid var(--border);
}

.department-featured {
  padding: clamp(1.25rem, 3vw, 1.75rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
}

.dept-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.625rem;
}

.dept-index {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--accent);
}

.dept-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.25rem, 2.2vw, 1.5rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.dept-desc {
  margin: 0 0 1rem;
  max-width: 54ch;
  color: var(--ink-muted);
}

.dept-scope {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
}

.dept-scope li {
  position: relative;
  padding-left: 1.125rem;
  font-size: 0.9375rem;
  color: var(--ink);
}

.dept-scope li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background-color: var(--accent);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 1.25rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.footer-meta {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.25rem;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 0.25rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 160ms ease;
}

.footer-link:hover {
  color: var(--accent);
}

/* Motion (MOTION 2: purposeful one-time reveal + crisp SVG draw, zero loops) */
@media (prefers-reduced-motion: no-preference) {
  .hero-copy {
    animation: settle-in 320ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .hero-plate {
    animation: settle-in 360ms cubic-bezier(0.2, 0.7, 0.2, 1) 40ms both;
  }

  .diag-arc-mid {
    stroke-dasharray: 320;
    stroke-dashoffset: 320;
    animation: draw-line 520ms cubic-bezier(0.22, 0.61, 0.36, 1) 80ms forwards;
  }

  .diag-wave {
    stroke-dasharray: 460;
    stroke-dashoffset: 460;
    animation: draw-line 560ms cubic-bezier(0.22, 0.61, 0.36, 1) 120ms forwards;
  }

  .diag-sun {
    transform-origin: 210px 176px;
    animation: sun-rise 420ms cubic-bezier(0.2, 0.75, 0.2, 1) 60ms both;
  }

  @keyframes settle-in {
    from {
      opacity: 0.88;
      translate: 0 8px;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }

  @keyframes draw-line {
    to {
      stroke-dashoffset: 0;
    }
  }

  @keyframes sun-rise {
    from {
      opacity: 0.4;
      transform: scale(0.92);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }
}

/* ==========================================================================
   Responsive Reflow (3 explicit width bands: Phone < 640px, Tablet 640-979px, Desktop >= 980px)
   ========================================================================== */

/* Compact mobile header and spec-row reflow so nothing wraps awkwardly or collides */
@media (max-width: 479px) {
  .nav-link:not(.nav-link-primary) {
    display: none;
  }

  .spec-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.15rem;
    padding-block: 0.75rem;
  }

  .spec-row-link {
    padding-bottom: 0.375rem;
  }

  .spec-row dt {
    font-size: 0.84375rem;
  }
}

/* Tablet & small laptop band */
@media (min-width: 640px) {
  .input-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .department-list {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    align-items: start;
    gap: 2rem;
  }

  .department-item:not(.department-featured) {
    padding-top: 1.5rem;
  }
}

/* Desktop asymmetric editorial layout */
@media (min-width: 980px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.18fr) minmax(0, 0.82fr);
    align-items: center;
  }

  .catalog-layout {
    grid-template-columns: minmax(0, 0.34fr) minmax(0, 0.66fr);
    align-items: start;
  }
}
