:root {
  --paper: #f3f0e8;
  --ink: #161616;
  --muted: #77746e;
  --line: rgba(22, 22, 22, .22);
  --mono: "IBM Plex Mono", monospace;
  --display: "Archivo Narrow", "Arial Narrow", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
}

button, a { color: inherit; }
button { font: inherit; }
a { text-decoration: none; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  padding: 24px clamp(20px, 3vw, 58px);
  font-size: 10px;
  letter-spacing: .12em;
}

.wordmark { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.wordmark-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.nav { display: flex; gap: clamp(22px, 3vw, 52px); }
.nav a { position: relative; padding-bottom: 4px; }
.nav a::after { content: ""; position: absolute; inset: auto 0 0; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: right; transition: transform .25s ease; }
.nav a:hover::after, .nav a:focus-visible::after { transform: scaleX(1); transform-origin: left; }
.edition { justify-self: end; text-align: right; line-height: 1.45; color: var(--muted); }

.generator {
  min-height: calc(100svh - 62px);
  padding: clamp(74px, 13vh, 170px) clamp(20px, 3vw, 58px) 36px;
  display: flex;
  flex-direction: column;
}

.intro {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin: 0 auto 16px;
  font-size: 9px;
  letter-spacing: .16em;
  color: var(--muted);
}
.intro b { font-weight: 400; color: var(--ink); }

.brief-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.1fr 1.1fr 1.5fr;
  width: 100%;
  margin: 0 auto;
  border-top: 1px solid var(--ink);
}

.brief-field {
  position: relative;
  min-width: 0;
  min-height: clamp(210px, 24vh, 270px);
  padding: 15px clamp(16px, 2.25vw, 38px) 20px 0;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  animation: briefReveal .55s cubic-bezier(.2,.8,.2,1) backwards;
}
.brief-field:nth-child(2) { animation-delay: .12s; }
.brief-field:nth-child(3) { animation-delay: .24s; }
.brief-field:nth-child(4) { animation-delay: .36s; }
@keyframes briefReveal { from { opacity: 0; transform: translateY(12px); } }
.brief-field:not(:first-child) { padding-left: clamp(16px, 2.25vw, 38px); border-left: 1px solid var(--line); }
.brief-field:last-child { padding-right: 0; }

.field-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 25px;
  margin-bottom: 34px;
  font-size: 9px;
  letter-spacing: .15em;
  color: var(--muted);
  white-space: nowrap;
}
.brief-field.is-active-step .field-meta { color: var(--ink); }
.brief-field.is-active-step { background: rgba(22, 22, 22, .025); }
.brief-field.is-disabled { opacity: .28; }
.brief-field.is-disabled .reroll { pointer-events: none; }
.field-tools { display: flex; align-items: center; gap: 9px; }
.field-tools button, .secondary-actions button {
  padding: 3px 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 8px;
  letter-spacing: .1em;
}
.reroll { opacity: 0; transform: translateX(5px); transition: opacity .2s, transform .2s; font-size: 15px !important; line-height: 1; }
.brief-field:hover .reroll, .reroll:focus-visible { opacity: 1; transform: none; }
.lock { color: var(--muted); }
.lock span { font-size: 11px; }
.brief-field.is-locked .lock { color: var(--ink); }
.brief-field.is-locked .lock span { font-size: 0; }
.brief-field.is-locked .lock span::after { content: "●"; font-size: 9px; }

.field-value {
  margin: 0;
  max-width: 100%;
  font-family: var(--display);
  font-size: clamp(29px, 2.35vw, 43px);
  font-weight: 600;
  line-height: .9;
  letter-spacing: -.035em;
  text-transform: uppercase;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.brief-field[data-key="mood"] .field-value { font-size: clamp(25px, 1.75vw, 34px); }
.field-value.is-long { font-size: clamp(23px, 1.65vw, 31px); }
.field-value.is-very-long { font-size: clamp(21px, 1.45vw, 27px); line-height: .95; }
.field-value.is-cycling { animation: slot .12s ease-in-out infinite alternate; }
@keyframes slot { to { opacity: .38; transform: translateY(3px); } }

.swatches {
  display: flex;
  width: 100%;
  height: 54px;
  margin: -15px 0 18px;
  overflow: hidden;
  border: 1px solid rgba(22, 22, 22, .35);
  background: #fff;
}
.swatch { flex: 1; min-width: 24px; transition: opacity .22s, transform .22s; }
.swatch + .swatch { border-left: 1px solid rgba(246, 244, 238, .8); }
.swatches.is-changing .swatch { opacity: .42; transform: translateY(3px); }
.palette-name { max-width: 290px; font-size: clamp(22px, 1.8vw, 33px); }
.palette-hex { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 0; font-size: 8px; line-height: 1.35; letter-spacing: .08em; color: var(--muted); }
.palette-hex span { white-space: nowrap; }

.roll-scope {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin: clamp(34px, 5vh, 54px) auto 0;
  font-size: 8px;
  letter-spacing: .12em;
}
.scope-label { color: var(--muted); }
.scope-options { display: flex; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.scope-options button {
  min-height: 32px;
  padding: 0 13px;
  border: 0;
  border-right: 1px solid rgba(22, 22, 22, .12);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 8px;
  letter-spacing: .1em;
  transition: background .2s, color .2s, opacity .2s, box-shadow .2s;
}
.scope-options button:last-child { border-right: 0; }
.scope-options button span { margin-right: 6px; opacity: .55; }
.scope-options button[aria-pressed="true"] {
  background: rgba(22, 22, 22, .045);
  color: var(--ink);
  box-shadow: inset 0 -2px var(--ink);
}
.scope-options button[aria-pressed="false"] { opacity: .38; text-decoration: line-through; }

.actions {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 42px;
  margin: clamp(34px, 5vh, 58px) auto 0;
  transform: translateX(56px);
}
.generate-button {
  width: 124px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  font-size: 10px;
  letter-spacing: .15em;
  transition: background .2s, color .2s, transform .2s;
}
.generate-button:hover { background: transparent; color: var(--ink); }
.generate-button:active { transform: translateY(2px); }
.generate-button:disabled { cursor: wait; opacity: .6; }
.secondary-actions { display: grid; gap: 8px; padding-top: 3px; }
.secondary-actions button { width: max-content; color: var(--muted); border-bottom: 1px solid transparent; }
.secondary-actions button:hover { color: var(--ink); border-color: var(--ink); }

.index-line { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 60px; font-size: 8px; letter-spacing: .15em; color: var(--muted); }
.index-line span { flex: 1; height: 1px; background: var(--line); }
.index-line b { font-weight: 400; }

.info-grid {
  display: grid;
  grid-template-columns: 1fr 2fr 2fr;
  gap: 30px;
  padding: 90px clamp(20px, 3vw, 58px);
  border-top: 1px solid var(--ink);
  font-family: var(--display);
  font-size: clamp(18px, 1.6vw, 28px);
  line-height: 1;
}
.info-grid p { margin: 0; }
.info-grid .info-label { font-family: var(--mono); font-size: 9px; letter-spacing: .15em; color: var(--muted); }
.site-footer { display: flex; justify-content: space-between; padding: 18px clamp(20px, 3vw, 58px); border-top: 1px solid var(--line); font-size: 8px; letter-spacing: .12em; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

@media (max-width: 1180px) {
  .brief-grid, .intro { width: 100%; }
  .brief-grid { grid-template-columns: 1fr 1fr; }
  .brief-field { min-height: 180px; }
  .brief-field:nth-child(3) { padding-left: 0; border-left: 0; }
  .brief-field:nth-child(2), .brief-field:nth-child(4) { padding-left: 28px; }
  .actions { transform: none; }
}

@media (max-width: 620px) {
  .site-header { grid-template-columns: 1fr auto; padding-top: 18px; }
  .nav { display: none; }
  .generator { min-height: 100svh; padding-top: 74px; }
  .intro { margin-bottom: 12px; }
  .brief-grid { display: block; }
  .brief-field, .brief-field:not(:first-child), .brief-field:nth-child(2), .brief-field:nth-child(4) {
    min-height: 0;
    padding: 12px 0 22px;
    border-left: 0;
  }
  .field-meta { margin-bottom: 22px; }
  .field-value { max-width: 90%; font-size: clamp(34px, 12vw, 48px); }
  .field-value.is-long { font-size: clamp(30px, 9.5vw, 42px); }
  .field-value.is-very-long { font-size: clamp(27px, 8.5vw, 38px); }
  .reroll { opacity: 1; transform: none; }
  .palette-field { padding-bottom: 25px !important; }
  .swatches { width: 100%; height: 48px; margin-top: -8px; }
  .palette-name { font-size: 30px; }
  .roll-scope { display: block; margin-top: 34px; }
  .scope-label { display: block; margin-bottom: 10px; }
  .scope-options { display: grid; grid-template-columns: 1fr 1fr; }
  .scope-options button { min-height: 38px; text-align: left; border-bottom: 1px solid var(--line); }
  .scope-options button:nth-child(2) { border-right: 0; }
  .scope-options button:nth-child(3), .scope-options button:nth-child(4) { border-bottom: 0; }
  .actions { justify-content: flex-start; gap: 28px; margin-top: 34px; }
  .index-line { padding-top: 70px; }
  .info-grid { grid-template-columns: 1fr; padding-top: 56px; padding-bottom: 56px; }
  .site-footer { display: grid; gap: 8px; }
  .site-footer span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
