/* ehsto.dev — app chrome
 *
 * Styles for ehsto.dev's own UI:
 *   · Style Guide (component entry, colour grid, settings controls)
 *   · Doc sections (Style Guide + Core long-form pages)
 *   · Brief intake (editor, preview, progress, actions)
 *
 * These rules are NOT part of the portable design system. Consuming
 * projects load style.css alone; ehsto.dev loads style.css + this file.
 *
 * Load order in index.html matters: style.css FIRST, app.css SECOND.
 * Rules here can extend or override framework primitives via the
 * cascade — but only because they come later.
 */



/* ─── STYLE GUIDE: COMPONENT ENTRY ───────────────────────── */
/* Each entry inside a Style Guide → Sections page. Live preview on a
 * recessed surface so it stands apart from the page; an open <details>
 * panel below shows the HTML in a code block with a copy button. */
.component {
  margin-bottom: var(--space-42);
  padding-bottom: var(--space-30);
  border-bottom: 1px solid var(--color-background-brighter);
}

.component:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

.component__preview {
  padding: var(--space-18);
  background-color: var(--color-background-darker);
  border: 1px solid var(--color-background-brighter);
  margin: var(--space-12) 0;
}

.component__code {
  margin-top: var(--space-9);
}

.component__code > summary {
  cursor: pointer;
  font-family: var(--font-family-02);
  font-size: var(--fs-small);
  color: var(--color-foreground-darker);
  padding: var(--space-6) 0;
  text-transform: uppercase;
  letter-spacing: 0.06rem;
  list-style: none;
  user-select: none;
}

.component__code > summary::-webkit-details-marker {
  display: none;
}

.component__code > summary::before {
  content: '▸ ';
  display: inline-block;
  width: var(--space-12);
  transition: transform 0.15s ease;
}

.component__code[open] > summary::before {
  content: '▾ ';
}

.component__code > summary:hover {
  color: var(--color-foreground);
}

.component__code pre {
  margin: var(--space-6) 0 0 0;
}

.component__copy {
  margin-top: var(--space-9);
}

.component__copy.is-copied {
  color: var(--color-accent-01);
  border-color: var(--color-accent-01);
}

.component__copy.is-error {
  color: var(--color-accent-02);
  border-color: var(--color-accent-02);
}

/* ─── STYLE GUIDE: COLOUR GRID ───────────────────────────── */
/* Pill swatches in a responsive multi-column layout. Each .color-grid__cell
 * stacks: pill swatch, token key (mono on recessed surface), description. */
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-30) var(--space-18);
  padding: var(--space-30) 0;
}

.color-grid__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
}

.color-grid__preview {
  display: block;
  width: 100%;
  max-width: 180px;
  height: 48px;
  border-radius: 24px;
  border: 1px solid var(--color-foreground-darker);
}

.color-grid__token {
  font-family: var(--font-family-02);
  font-size: var(--fs-small);
  color: var(--color-foreground);
  background-color: var(--color-background-darker);
  padding: var(--space-3) var(--space-9);
  border-radius: 2px;
  margin-top: var(--space-9);
  word-break: break-all;
}

.color-grid__description {
  font-family: var(--font-family-01);
  font-size: var(--fs-small);
  color: var(--color-foreground-darker);
  line-height: 1.4;
  margin-top: var(--space-6);
  max-width: 240px;
}

/* Editable swatch — native colour input wearing the same pill shape as
 * the read-only preview. */
.color-grid__swatch {
  display: block;
  width: 100%;
  max-width: 180px;
  height: 48px;
  border-radius: 24px;
  border: 1px solid var(--color-foreground-darker);
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.color-grid__swatch::-webkit-color-swatch-wrapper { padding: 0; border-radius: 24px; }
.color-grid__swatch::-webkit-color-swatch { border: 0; border-radius: 24px; }
.color-grid__swatch::-moz-color-swatch { border: 0; border-radius: 24px; }

.color-grid__value {
  width: 100% !important;
  max-width: 160px;
  margin-top: var(--space-9);
  text-align: center;
  font-size: var(--fs-small) !important;
  padding: var(--space-3) var(--space-9) !important;
}

.color-grid__reset {
  margin-top: var(--space-6);
}

/* ─── STYLE GUIDE: SETTINGS CONTROLS ─────────────────────── */
/* Font-family picker — label + dropdown + live preview. */
.font-picker {
  margin-bottom: var(--space-30);
}

.font-picker select {
  width: 100%;
  max-width: 360px;
  margin-bottom: var(--space-9);
}

.font-picker__preview {
  font-size: 1.25rem;
  padding: var(--space-18);
  background-color: var(--color-background-darker);
  border: 1px solid var(--color-background-brighter);
  line-height: 1.4;
}

/* Token-row layout used by typography (editable) and spacing (read-only).
 * Three columns: key | value (editable input or static text) | reset / preview. */
.settings-token {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 1.4fr) 1fr;
  gap: var(--space-12);
  padding: var(--space-9) 0;
  border-bottom: 1px solid var(--color-background-brighter);
  align-items: center;
}

.settings-token:last-child {
  border-bottom: 0;
}

.settings-token__key {
  font-family: var(--font-family-02);
  font-size: var(--fs-small);
  color: var(--color-foreground);
}

.settings-token__value {
  font-size: var(--fs-small);
  color: var(--color-foreground-darker);
}

.settings-token__input {
  width: 100% !important;
  font-size: var(--fs-small) !important;
  padding: var(--space-3) var(--space-9) !important;
}

/* Spacing preview — a horizontal accent-01 bar at the token's width. */
.spacing-preview {
  height: var(--space-9);
  background-color: var(--color-accent-01);
  border-radius: 2px;
  max-width: 100%;
}

/* Typography examples — each entry on the Style Guide → Settings →
 * Typography page. Eyebrow label above the live element. Eyebrow uses
 * default .eyebrow styling but with a small bottom margin to separate
 * from the element it describes. Resets any inherited margin on the first
 * heading inside so adjacent examples don't push apart vertically. */
.type-example {
  margin-bottom: var(--space-30);
  padding-bottom: var(--space-18);
  border-bottom: 1px dashed var(--color-background-brighter);
}

.type-example:last-of-type {
  border-bottom: 0;
  margin-bottom: 0;
}

.type-example > .eyebrow {
  display: block;
  margin-bottom: var(--space-12);
}

/* Reset margins on most elements so adjacent examples sit cleanly next to
 * each other. h2 is intentionally NOT reset — it has a distinctive top
 * border that's part of its identity, and the example must show it
 * accurately, including the spacing the real element claims. */
.type-example > h1,
.type-example > h3,
.type-example > h4,
.type-example > h5,
.type-example > h6,
.type-example > p {
  margin: 0;
}

/* Borders reference — grid of example boxes showing each border style. */
.border-examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-18);
  margin-top: var(--space-18);
}

.border-examples__cell {
  padding: var(--space-18);
  font-size: var(--fs-small);
  line-height: 1.5;
  text-align: center;
}

.border-examples__cell code {
  font-size: 0.65rem;
  word-break: break-all;
}

/* ─── DOC SECTIONS (Style Guide + Core long-form pages) ──── */
/* Long-form pages render in two modes:
 *   - Mobile (default, <1024px): each .doc-section is a self-contained
 *     card with .doc-section__bar as the tap target and a collapsible
 *     body. Sidebar is hidden.
 *   - Desktop (≥1024px, overrides below): one continuous main column;
 *     bar/body wrapper become layout no-ops; the eyebrow + h2 inside the
 *     body provide the heading and each section is separated by a 1px
 *     border-bottom. Sidebar carries scroll-nav.
 * Mobile-first per project rule: never use max-width media queries. */

/* Each .doc-section is a self-contained card with a tap-target
 * header and a collapsible body. Border + background match the rest
 * of the framed-card aesthetic. */
.doc-section {
  scroll-margin-top: var(--space-90);
  margin: 0 -18px var(--space-9) -18px;
  padding-bottom: 0;
  border: 0px solid var(--color-background-brighter);
  background-color: var(--color-background);
}

.doc-section:last-child {
  margin-bottom: 0;
}

.doc-section__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--space-42);
  padding: 0 var(--space-12);
  margin: 0px 6px;
  background-color: var(--color-background);
  cursor: pointer;
  border-bottom: 0px solid var(--color-background-brighter);
  transition: background-color 0.2s ease;
}

.doc-section__bar:hover {
  background-color: var(--color-background-darker);
}

.doc-section__title {
  font-family: var(--font-family-01);
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--color-foreground);
  text-transform: capitalize;
}

.doc-section__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--color-foreground);
  cursor: pointer;
  transition: transform 0.2s ease;
}

/* Chevron points UP when expanded (click to collapse); rotates 180°
 * to point DOWN when collapsed (click to expand). Mirrors .card__toggle. */
.doc-section--collapsed .doc-section__toggle {
  transform: rotate(180deg);
}

.doc-section--collapsed .doc-section__bar {
  border-bottom: 0;
}

.doc-section__body {
  display: block;
  padding: var(--space-18);
}

.doc-section--collapsed .doc-section__body {
  display: none;
}

/* Hide the inline eyebrow + h2 inside the body — the .doc-section__bar
 * already shows the section title. Saves vertical space and avoids
 * the duplicate-heading awkwardness. Desktop block below restores them. */
.doc-section__body > .eyebrow:first-child,
.doc-section__body > h1:first-of-type,
.doc-section__body > h2:first-of-type {
  display: none;
}

/* Group headers (Style Guide only — three card groups). Bigger,
 * bordered, generous spacing — they break the long card stack into
 * the three sidebar groups so users can still see the structure
 * without the actual sidebar. Match h2 exactly. Hidden at desktop. */
.doc-group-header {
  display: block;
  font-family: var(--font-family-01);
  font-size: var(--fs-h2);
  font-weight: 600;
  color: var(--color-foreground);
  border-top: 3px solid var(--color-foreground);
  line-height: 1.3;
  padding-top: 18px;
  margin: var(--space-60) 0 var(--space-42) 0;
}

.doc-group-header:first-of-type {
  margin-top: var(--space-30);
}

@media (min-width: 1024px) {
  /* Section becomes a regular block in a continuous column. */
  .doc-section {
    margin: 0 0 var(--space-42) 0;
    padding-bottom: var(--space-42);
    border: 0;
    border-bottom: 1px solid var(--color-background-brighter);
    background-color: transparent;
  }

  .doc-section:last-child {
    border-bottom: 0;
    margin-bottom: 0;
    padding-bottom: 0;
  }

  /* The bar is invisible chrome on desktop; the body shows unconditionally. */
  .doc-section__bar {
    display: none;
  }

  .doc-section__body {
    padding: 0;
  }

  /* Collapsed state has no effect at desktop — the body always shows. */
  .doc-section--collapsed .doc-section__body {
    display: block;
  }

  /* Restore inline eyebrow + h1/h2 that were hidden at mobile. */
  .doc-section__body > .eyebrow:first-child {
    display: inline;
  }
  .doc-section__body > h1:first-of-type,
  .doc-section__body > h2:first-of-type {
    display: block;
  }

  /* Group headers redundant at desktop — sidebar carries the structure. */
  .doc-group-header {
    display: none;
  }
}

/* ─── BRIEF: EDITOR (Create Project sidebar inputs) ──────── */
/* The Create Project page renders the brief as an editor in the sidebar
 * (one step card per field, with the field's editor inside the card
 * body) and a read-only preview in the main column. The editor classes
 * are below; the preview classes follow in the next section. */
.brief-doc {
  margin: var(--space-30) 0 var(--space-42);
}

.brief-doc__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-12);
  margin-bottom: var(--space-15);
}

/* Restore a small gap below the last meta block so it doesn't sit flush
 * against the first labelled field of the brief body. */
.brief-doc__meta:last-of-type {
  margin-bottom: var(--space-18);
}

/* Inside the meta blocks (Project ID / Project type) the section-heading
 * label sits inline next to the value — drop the big top margin and the
 * scroll-anchor offset it carries in the brief body. */
.brief-doc__meta .brief-doc__section-heading {
  margin: 0;
  scroll-margin-top: 0;
}

.brief-doc__type-toggle {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
}

/* Project ID — auto-generated and persisted on the first edit to the
 * brief, then displayed as a static value. Em-dash placeholder shows
 * before the first edit. */
.brief-doc__id-value {
  color: var(--color-foreground);
  font-size: var(--fs-body);
}

.brief-doc__type-btn {
  background: transparent;
  border: 0;
  padding: 0;
  font-family: var(--font-family-01);
  font-size: var(--fs-body);
  color: var(--color-foreground-darker);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.brief-doc__type-btn:hover {
  color: var(--color-foreground);
  text-decoration-color: var(--color-foreground-darker);
}

.brief-doc__type-btn.is-active {
  color: var(--color-foreground);
  font-weight: 600;
  text-decoration-color: var(--color-foreground);
}

.brief-doc__type-sep {
  color: var(--color-foreground-darker);
  padding: 0 var(--space-3);
}

.brief-doc__section-heading {
  margin: var(--space-42) 0 var(--space-9) 0;
  scroll-margin-top: var(--space-90);
}

/* Editable fields — native <input> for the title, <textarea> for the
 * subtitle and section bodies. Compound selectors (input.x / textarea.x)
 * give 0,0,1,1 specificity so they beat the global input/textarea base
 * styles defined earlier in the file. field-sizing: content lets
 * textareas grow with their content (modern browsers); min-height covers
 * the floor for older ones. */
input.brief-doc__title,
textarea.brief-doc__subtitle,
textarea.brief-doc__body {
  display: block;
  width: 100%;
  background-color: var(--color-background-darker);
  color: var(--color-foreground);
  font-family: var(--font-family-01);
  font-weight: 600;
  opacity: 1;
  padding: var(--space-3) 0;
  resize: none;
  field-sizing: content;
}

input.brief-doc__title {
  font-size: var(--fs-h1);
  line-height: 1.3;
  letter-spacing: normal;
  margin: 0;
  min-height: 3.6rem;
}

textarea.brief-doc__subtitle {
  font-size: var(--fs-h4);
  line-height: 1.4;
  letter-spacing: normal;
  margin: var(--space-12) 0 var(--space-18) 0;
  min-height: 1.5rem;
}

textarea.brief-doc__body {
  font-size: var(--fs-body);
  font-weight: normal;
  line-height: 1.6;
  letter-spacing: 0.01rem;
  margin: var(--space-12) 0;
  min-height: 6rem;
}

input.brief-doc__title:focus,
textarea.brief-doc__subtitle:focus,
textarea.brief-doc__body:focus {
  padding-left: var(--space-9);
  padding-right: var(--space-9);
}

/* Placeholder hint — sibling .hint element above each editable field.
 * Uses the global .hint styling (small, muted). Always visible — stays
 * as persistent helper text whether the field is empty or filled. */
.brief-doc__field-hint {
  margin: var(--space-3) 0;
}

/* ─── BRIEF: PREVIEW (Create Project main column read-only) ─ */
/* Read-only render of the brief, shown in the main column. Editor lives
 * in the sidebar; this preview reflects the user's input live. Unedited
 * fields carry the .is-empty modifier so their placeholder text shows in
 * --color-foreground-darker. */
.brief-preview {
  padding: var(--space-24) 0 var(--space-42);
  margin: 0px;
  max-width: 660px;
}

@media (min-width: 768px) {
  .brief-preview {
  margin: var(--space-21);
  padding: var(--space-30);
}
}

.brief-preview__title {
  font-family: var(--font-family-01);
  font-size: var(--fs-h1);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 var(--space-21) 0;
}

.brief-preview__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-24);
  font-size: var(--fs-small);
  text-transform: uppercase;
  color: var(--color-foreground);
  margin: 0 0 var(--space-60) 0;
  padding-bottom: var(--space-18);
  border-bottom: 1px solid var(--color-foreground-darker);
}

/* Project-type options in the preview meta line — all three labels
 * rendered inline. Active one shows in --color-foreground; the other
 * two carry .is-empty for the muted --color-foreground-darker. */
.brief-preview__type {
  color: var(--color-foreground);
  text-transform: uppercase;
}

.brief-preview__type-sep {
  color: var(--color-foreground-darker);
  padding: 0 var(--space-3);
}

.brief-preview__subtitle {
  font-family: var(--font-family-01);
  font-size: var(--fs-h4);
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 var(--space-30) 0;
}

/* Section label — small uppercase eyebrow shown above each section
 * paragraph in the preview (cards 4–12). Helps the user locate
 * specific brief content at a glance. The title and subtitle don't
 * carry labels because their content speaks for itself. */
.brief-preview__section-label {
  display: block;
  font-size: var(--fs-small);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06rem;
  color: var(--color-foreground);
  margin: var(--space-24) 0 var(--space-6) 0;
}

.brief-preview__section {
  font-size: var(--fs-body);
  line-height: 1.6;
  letter-spacing: 0.01rem;
  margin: 0 0 var(--space-18) 0;
  white-space: pre-wrap;
}

/* Shared empty-state modifier — mutes unedited preview text. */
.brief-preview .is-empty {
  color: var(--color-foreground-darker);
}

/* ─── BRIEF: PROGRESS + ACTIONS ──────────────────────────── */
/* Wrapper for the always-visible progress bar in the Create Project
 * sidebar. Not collapsible (unlike step cards below it). Sticky at the
 * top of the scrolling sidebar so the bar stays in view even when the
 * sidebar's internal scroll position moves down through the step list. */
.progress-bar-wrapper {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: var(--color-background);
  border: 1px solid var(--color-background-brighter);
  padding: var(--space-12);
}

/* Progress indicator visual — slim accent-01 fill on a darker track,
 * with the filled / total / percent text below. */
.brief-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  margin: var(--space-12) var(--space-6);
}

.brief-progress__bar {
  height: 4px;
  background-color: var(--color-background-darker);
  border: 1px solid var(--color-background-brighter);
  overflow: hidden;
}

.brief-progress__fill {
  height: 100%;
  background-color: var(--color-accent-01);
  transition: width 0.2s ease;
}

.brief-progress__text {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-12);
  font-family: var(--font-family-02);
  font-size: var(--fs-small);
  color: var(--color-foreground-darker);
}

.brief-progress__text #brief-save-indicator {
  margin-left: auto;
}

/* Action bar at the bottom of the brief. Download on the far left,
 * Clear draft on the far right (destructive action kept away from the
 * primary download). Both buttons use the small size modifier. */
.brief-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-9);
  padding: var(--space-21);
  background-color: var(--color-background);
  border: 1px solid var(--color-background-brighter);
}
