/* Soulstice — layout and components.
   Grid law: full-height red rules frame the reading column;
   blocks hold to the vertical rhythm; negative space sits between blocks. */

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

html { background: var(--ground); }

/* Line-breaking hygiene: keep last lines from ending on a single word, and
   balance short headings. A browser hint, not a guarantee. */
p, li, blockquote, .card__q, figcaption { text-wrap: pretty; }
h1, h2, h3, .welcome__h, .page__h1, .page__h2, .modeselect__title { text-wrap: balance; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--unit);
  letter-spacing: var(--tracking);
  -webkit-font-smoothing: antialiased;
}

/* Full view: let the fixed #backdrop canvas show through the page body and the
   frame. Every readable block sits on an opaque .screen-panel card; header and
   footer are their own opaque bands. The galaxy shows in the margins around
   each panel, never behind readable text. */
:root[data-view="full"] body { background: transparent; }

/* ---- Frame: two full-height red vertical rules around the column ---- */

.frame {
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 0.5rem;
  border-left: var(--rule-w) solid var(--rule);
  border-right: var(--rule-w) solid var(--rule);
  /* Grow to fill the viewport so the red rules run full height and the footer
     is always pushed to the bottom, however short the page. */
  flex: 1 0 auto;
}

.chrome {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: var(--step) 0;
  border-bottom: var(--rule-w) solid var(--rule);
}

.chrome__home {
  font-family: var(--font-display);
  font-size: var(--fs-small);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red-text);
  text-decoration: none;
}

.chrome__ground {
  font-family: var(--font-display);
  font-size: var(--fs-small);
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: transparent;
  border: var(--rule-w) solid var(--field-border);
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}
.chrome__ground:hover { color: var(--ink); border-color: var(--ink-soft); }

.screen {
  padding: calc(var(--step) * 2) 0;
}

/* ---- The panel: every screen's readable content sits on this opaque card,
   with the backdrop showing in the margin on all four sides. One rule for
   welcome, mode-select, all six modes, the arc-break, the card renderer's
   output, the generated-document screen, privacy and 404. ---- */

#screen > * {
  background: var(--surface);
  border: var(--rule-w) solid #565656;
  padding: calc(var(--step) * 1.5) calc(var(--step) * 1.4);
  margin: 0 clamp(0.5rem, 1.6vw, 1.1rem) calc(var(--step) * 1.25);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
}
#screen > *:last-child { margin-bottom: 0; }

/* The panel takes programmatic focus on every route change so screen-reader and
   keyboard users land on the new screen. It is not an interactive control, so it
   shows no focus ring of its own (mobile Safari draws a blue-grey box otherwise);
   the real controls inside it keep their own :focus-visible outlines. */
#screen:focus,
#screen:focus-visible,
#screen > *:focus,
#screen > *:focus-visible { outline: none; }

:root[data-view="light"] #screen > * {
  border-color: var(--haze);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.12);
}

@media (max-width: 560px) {
  #screen > * {
    margin-inline: 0.5rem;
    padding: calc(var(--step) * 1.2) 1.1rem;
  }
}

/* ---- Shared display bits ---- */

.card__label,
.modeselect__title,
.card__q,
.mode__name {
  font-family: var(--font-display);
  font-weight: 400;
}

.card__label {
  display: block;
  font-size: var(--fs-small);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red-text);
  margin-bottom: var(--step);
}

.card__q {
  font-size: var(--fs-q);
  line-height: 1.35;
  margin: 0 0 var(--step);
  color: var(--ink);
}

.card__note {
  font-size: var(--fs-small);
  color: var(--ink-soft);
  margin: calc(var(--step) * -0.4) 0 var(--step);
}

/* ---- Card / form ---- */

.card { display: block; }

.card__form { margin-top: calc(var(--step) * 1.5); }

.opts { list-style: none; margin: 0 0 var(--step); padding: 0; }

.opt {
  display: grid;
  grid-template-columns: 1.4rem 1fr;
  gap: 0.2rem 0.9rem;
  padding: var(--step) 0;
  border-top: var(--rule-w) solid var(--field-border);
}
.opt:last-child { border-bottom: var(--rule-w) solid var(--field-border); }

.opt__input { margin-top: 0.35rem; accent-color: var(--red); width: 1rem; height: 1rem; }

.opt__label { display: block; cursor: pointer; }

.opt__text { display: block; color: var(--ink); }

.opt__desc {
  display: block;
  font-size: var(--fs-small);
  color: var(--ink-soft);
  margin-top: 0.35rem;
}

.opt--other .opt__label { margin-bottom: 0.5rem; }

.field {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-body);
  color: var(--ink);
  background: var(--field-bg);
  border: var(--rule-w) solid var(--field-border);
  padding: 0.6rem 0.7rem;
  width: 100%;
}
.field:focus { outline: 2px solid var(--red); outline-offset: 1px; }

.field--other { grid-column: 2; }

.field--open { display: block; min-height: 8rem; resize: vertical; }

/* ---- Buttons ---- */

.btn {
  font-family: var(--font-display);
  font-size: var(--fs-small);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--btn-ink);
  background: var(--btn-bg);
  border: none;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { background: var(--btn-disabled-bg); color: var(--btn-disabled-ink); cursor: not-allowed; filter: none; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn--block { display: block; width: 100%; margin-top: var(--step); text-align: center; }

.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border: var(--rule-w) solid var(--field-border);
}
.btn--ghost:hover { color: var(--ink); border-color: var(--ink-soft); }

.btn--continue { margin-top: var(--step); }

/* ---- Mode select ---- */

.modeselect__title {
  font-size: var(--fs-title);
  color: var(--ink);
  margin: 0 0 0.4rem;
  letter-spacing: 0.02em;
}

.modeselect__sub {
  color: var(--ink-soft);
  margin: 0 0 calc(var(--step) * 2);
}

.modes { list-style: none; margin: 0; padding: 0; }

.mode { border-top: var(--rule-w) solid var(--field-border); }
.mode:last-child { border-bottom: var(--rule-w) solid var(--field-border); }

.mode__btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: var(--step) 0;
  cursor: pointer;
  color: inherit;
}
.mode__btn:hover .mode__name { color: var(--red-text); }
.mode__btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.mode__name {
  display: block;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.mode__blurb {
  display: block;
  font-size: var(--fs-small);
  color: var(--ink-soft);
  margin-top: 0.35rem;
}

/* ---- Resume list on the landing screen ---- */

.resume-list { list-style: none; margin: 0 0 calc(var(--step) * 2); padding: 0; }
.resume-list__item { margin-bottom: 0.6rem; }
.resume-list .btn { width: 100%; text-align: left; }

/* ---- Panels: resume / done / stub / arc break ---- */

.screen-panel, .arcbreak { display: block; }

/* ---- Accessibility niceties ---- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.noscript {
  max-width: var(--column);
  margin: 4rem auto;
  padding: 0 var(--gutter);
  color: var(--ink);
  font-family: var(--font-body);
}

/* ---- M4: output screen (Compass and the other assembled documents) ---- */

.output { display: block; }

.output-doc {
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  margin-bottom: calc(var(--step) * 2);
}

.output-doc h1,
.output-doc h2,
.output-doc h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink);
  line-height: 1.25;
}
.output-doc h1 { font-size: var(--fs-h1); margin: 0 0 var(--step); }
.output-doc h2 {
  font-size: var(--fs-h2);
  letter-spacing: 0.02em;
  margin: calc(var(--step) * 1.6) 0 0.4rem;
  color: var(--red-text);
}
.output-doc h3 { font-size: var(--fs-h3); margin: var(--step) 0 0.3rem; }

.output-doc p { margin: 0 0 var(--step); }

.output-doc ul,
.output-doc ol { margin: 0 0 var(--step); padding-left: 1.2rem; }
.output-doc li { margin: 0.2rem 0; }

.output-doc hr {
  border: 0;
  border-top: var(--rule-w) solid var(--rule);
  margin: calc(var(--step) * 1.5) 0;
}

.output-doc blockquote {
  margin: 0 0 var(--step);
  padding-left: 0.9rem;
  border-left: 2px solid var(--rule);
  color: var(--ink-soft);
}

/* The Soulstice footnote: the final block of every generated document. */
.output-doc__footnote {
  margin-top: var(--step);
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

.output__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: var(--step) 0;
}

.btn--download {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.output__fortee {
  font-size: var(--fs-small);
  color: var(--ink-soft);
  border-top: var(--rule-w) solid var(--field-border);
  padding-top: var(--step);
  margin-top: var(--step);
}
.output__fortee a { color: var(--red-text); }

/* ---- The prompt kit: set apart from the red-ruled document ---- */

.llm-kit {
  margin-top: calc(var(--step) * 2);
  border: 2px solid var(--gunmetal);
  background: var(--field-bg);
  padding: calc(var(--step) * 1.2) calc(var(--step) * 1.2);
}
:root[data-view="light"] .llm-kit { border-color: var(--slate); }

.llm-kit__label { color: var(--ink-soft); margin-bottom: var(--step); }

.llm-kit__note {
  color: var(--ink);
  margin: 0 0 var(--step);
}

.llm-kit__intro {
  font-size: var(--fs-small);
  color: var(--ink-soft);
  margin: 0 0 var(--step);
}

.llm-kit__list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: llm;
}

.llm-kit__item {
  border-top: var(--rule-w) solid var(--field-border);
  padding: var(--step) 0;
}
.llm-kit__item:last-child { padding-bottom: 0; }

.llm-kit__name {
  counter-increment: llm;
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-small);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 0.6rem;
}
.llm-kit__name::before { content: counter(llm) " · "; color: var(--ink-soft); }

.llm-kit__text {
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--ink-soft);
  background: var(--surface);
  border: var(--rule-w) solid var(--field-border);
  padding: 0.8rem 0.9rem;
  margin: 0 0 0.7rem;
  white-space: pre-wrap;
}

.llm-kit__copy { margin-right: 0.6rem; }

.llm-kit__copied {
  font-size: var(--fs-small);
  color: var(--red-text);
}
.llm-kit__copied[hidden] { display: none; }
