/* App styles.
   Every value comes from a custom property in css/tokens.css.
   Never write a literal hex value in this file. */

/* Accessibility override of one vendored value.
   --mauve-400 measures 2.19:1 on --light-100 and 1.84:1 on --brand-warm, both below
   the 3:1 WCAG 1.4.11 minimum for the boundary of a user-interface control. Enso's own
   guide already warns the colour fails as text on light backgrounds; the same limit
   applies to control borders. --rose-700 is 7.56:1 and 6.35:1 on those grounds.
   Container borders keep the brand mauve — a panel is not a control.
   Delete this block and the var(--control-border) uses below to restore Enso's exact look. */
:root {
  --control-border: var(--rose-700);
}

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

body {
  margin: 0;
  background: var(--theme-background);
  color: var(--theme-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-text-main);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-relaxed);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: calc(var(--space-3) * -4);
  z-index: 10;
  padding: var(--space-2) var(--space-3);
  background: var(--brand-600);
  color: var(--dark-900);
  border-radius: var(--radius-round);
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: var(--space-3); }

/* No border or shadow between header, main and footer — an Enso rule. */
.site-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--nav-height);
  padding: 0 var(--site-margin);
  max-width: var(--site-max-width);
  margin: 0 auto;
}
.site-header__title {
  font-family: var(--font-mono);
  font-weight: var(--font-weight-book);
  font-size: var(--font-size-text-main);
  text-transform: uppercase;
  color: var(--rose-700);
}

main {
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--site-margin) var(--section-space-small);
}

.page-title {
  font-size: var(--font-size-h2);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-h1);
  margin: 0 0 var(--space-2);
}
.page-intro {
  margin: 0 0 var(--space-6);
  max-width: 52ch;
  font-weight: var(--font-weight-book);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--site-gutter);
  align-items: start;
}
.layout > * { min-width: 0; }

.panel {
  border: var(--border-width-main) solid var(--theme-border);
  border-radius: var(--radius-main);
  padding: var(--space-5);
}
.panel--sticky {
  position: sticky;
  top: var(--space-4);
  max-height: calc(100vh - var(--space-7));
  overflow-y: auto;
}
.panel__heading {
  font-size: var(--font-size-h5);
  margin: 0 0 var(--space-4);
}

/* Content-type tablist — a scrollable row of pills. */
.tabs {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
  scrollbar-width: thin;
}
.tab {
  flex: 0 0 auto;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border: var(--border-width-main) solid var(--control-border);
  border-radius: var(--radius-round);
  background: transparent;
  color: var(--rose-700);
  font-family: var(--font-mono);
  font-size: var(--font-size-text-small);
  font-weight: var(--font-weight-book);
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-selected='true'] {
  background: var(--rose-700);
  border-color: var(--rose-700);
  color: var(--light-100);
}

/* Forms — follows the Enso form spec exactly. */
.form-field { margin-bottom: var(--space-4); }
.form-label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--font-size-text-small);
  font-weight: var(--font-weight-semibold);
}
.form-input, .form-textarea, .form-select {
  font-family: var(--font-sans);
  font-size: var(--font-size-text-main);
  font-weight: var(--font-weight-semibold);
  color: var(--theme-text);
  background-color: var(--theme-background);
  border: var(--border-width-main) solid var(--control-border);
  border-radius: var(--radius-small);
  padding: var(--space-2) var(--space-3);
  width: 100%;
  min-height: 44px;
}
.form-textarea { min-height: 96px; resize: vertical; }

:is(.form-input, .form-textarea, .form-select, .form-panel, .tab, .btn, .btn-copy,
    .form-check__input, .preset, .skip-link, .custom-controls input[type='color']):focus-visible {
  outline: 3px solid var(--brand-600);
  outline-offset: 2px;
  border-color: var(--brand-600);
}

.form-hint {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-book);
  color: var(--rose-700);
}
.form-field--error .form-input,
.form-field--error .form-textarea,
.form-field--error .form-select { border-color: var(--error-400); }
.form-error {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-1);
  color: var(--error-400);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semibold);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0;                 /* the label supplies its own leading space, so no dead gap */
  min-height: 44px;
  margin-bottom: var(--space-3);
}
.form-check__input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  accent-color: var(--rose-700);
}
.form-check__label {
  display: flex;
  align-items: center;
  flex: 1;
  min-height: 44px;       /* clicking the label toggles the box, so the whole row is the target */
  padding-left: var(--space-2);
  font-size: var(--font-size-text-small);
  cursor: pointer;
}

.form-select-wrapper { position: relative; }

.field-group { border: 0; padding: 0; margin: 0 0 var(--space-4); }

/* Preview */
.preview {
  background: var(--theme-background);
  border-radius: var(--radius-main);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  display: flex;
  justify-content: center;
}
.preview__canvas { width: 100%; max-width: 320px; }
.preview__canvas svg { width: 100%; height: auto; display: block; }

/* Style presets */
.preset-group { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.preset {
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: var(--border-width-main) solid var(--control-border);
  border-radius: var(--radius-round);
  background: transparent;
  color: var(--theme-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-text-small);
  cursor: pointer;
}
.preset[aria-pressed='true'] {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: var(--dark-900);
}
.style-note, .global-error {
  margin: var(--space-2) 0 0;
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-book);
}
.style-note { color: var(--rose-700); }
.global-error { color: var(--error-400); font-weight: var(--font-weight-semibold); }

.custom-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.custom-controls input[type='color'] {
  width: 100%;
  min-height: 44px;
  padding: 2px;
  border: var(--border-width-main) solid var(--control-border);
  border-radius: var(--radius-small);
  background: var(--theme-background);
}

/* Buttons — always pill-shaped. */
.btn {
  padding: var(--space-2) var(--space-4);
  min-height: 44px;
  border-radius: var(--radius-round);
  border: var(--border-width-main) solid transparent;
  font-family: var(--font-sans);
  font-size: var(--font-size-text-small);
  font-weight: var(--font-weight-book);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  cursor: pointer;
}
.btn-primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-border);
  color: var(--btn-primary-text);
}
.btn-secondary {
  background: var(--btn-secondary-bg);
  border-color: var(--control-border);
  color: var(--btn-secondary-text);
}
.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: var(--font-size-text-small);
  color: var(--rose-700);
  border: var(--border-width-main) solid var(--mauve-400);
  border-radius: var(--radius-round);
  padding: 8px 18px;
  background: none;
  cursor: pointer;
}
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.site-footer {
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding: var(--space-5) var(--site-margin) var(--space-7);
  font-family: var(--font-mono);
  font-size: var(--font-size-text-small);
  font-weight: var(--font-weight-book);
  color: var(--rose-700);
}

@media (max-width: 991px) {
  :root {
    --site-margin: 20px;
    --font-size-h2: 28px;
  }
  .layout { grid-template-columns: 1fr; }
  .panel--sticky {
    position: static;
    max-height: none;      /* the cap only exists to keep a PINNED panel reachable; */
    overflow-y: visible;   /* once it flows with the page it must not trap its own content */
  }
  .custom-controls { grid-template-columns: 1fr; }
}

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