/*
 * layout.css — app shell, editorial masthead, numbered module index, and the
 * instrument-style control panels.
 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-grad);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

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

.mono { font-family: var(--mono); }
.tick { color: var(--accent); }

/* ----------------------------------------------------------- app header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px clamp(16px, 4vw, 44px);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  font-family: var(--mono);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.brand .logo {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-family: var(--display);
  font-size: 1rem;
  color: var(--accent);
}
.brand .logo::before { content: '◧'; }
.brand .label { display: flex; gap: 8px; align-items: baseline; }
.brand .label b { font-weight: 600; }
.brand .label small { color: var(--text-faint); font-size: .72rem; letter-spacing: .14em; }

.nav { display: flex; gap: 2px; margin-left: 6px; }
.nav-link {
  position: relative;
  padding: 9px 13px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .02em;
  cursor: pointer;
  border: none;
  background: none;
  transition: color var(--transition);
}
.nav-link::after {
  content: '';
  position: absolute; left: 13px; right: 13px; bottom: 4px;
  height: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--transition);
}
.nav-link:hover { color: var(--text); }
.nav-link--active { color: var(--text); }
.nav-link--active::after { transform: scaleX(1); }

.header-spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
}
.icon-btn:hover { border-color: var(--border-strong); transform: translateY(-1px); }

/* --------------------------------------------------------------- layout */
.container { max-width: var(--maxw); margin: 0 auto; padding: clamp(22px, 4vw, 52px); }

[data-view] { display: none; }
.view--active { display: block; }

/* staggered entrance */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.view--active .stagger > * { opacity: 0; animation: rise .6s cubic-bezier(.2, .7, .2, 1) forwards; }
.view--active .stagger > *:nth-child(1) { animation-delay: .02s; }
.view--active .stagger > *:nth-child(2) { animation-delay: .10s; }
.view--active .stagger > *:nth-child(3) { animation-delay: .18s; }
.view--active .stagger > *:nth-child(4) { animation-delay: .26s; }

/* --------------------------------------------------------------- masthead */
.hero { padding: clamp(26px, 7vw, 84px) 0 clamp(20px, 4vw, 40px); max-width: 1000px; }
.hero .index {
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 12px;
}
.hero .index::before { content: ''; width: 34px; height: 1px; background: var(--border-strong); }
.hero h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2.5rem, 7.4vw, 5.6rem);
  line-height: .98;
  letter-spacing: -.018em;
  margin: 22px 0 0;
  text-wrap: balance;
}
.hero h1 .amp {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  padding: 0 .06em;
}
.hero .lead {
  margin: 26px 0 0;
  max-width: 58ch;
  font-size: clamp(1.02rem, 1.5vw, 1.22rem);
  color: var(--text-dim);
}
.hero .lead b { color: var(--text); font-weight: 600; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

/* --------------------------------------------------------------- modules */
.section-rule {
  display: flex; align-items: center; gap: 16px;
  margin: clamp(34px, 6vw, 64px) 0 22px;
  font-family: var(--mono); font-size: .76rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--text-faint);
}
.section-rule::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.modules { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
@media (max-width: 760px) { .modules { grid-template-columns: 1fr; } }

.module {
  position: relative;
  display: block;
  text-align: left;
  padding: clamp(22px, 3vw, 34px);
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  overflow: hidden;
  transition: background var(--transition);
}
.modules .module:last-child { border-right: none; }
@media (max-width: 760px) { .module { border-right: none; border-bottom: 1px solid var(--border); } }
.module:hover { background: var(--surface-2); }
.module .num {
  position: absolute; top: 14px; right: 18px;
  font-family: var(--display); font-size: 3.4rem; font-weight: 600;
  color: var(--border); line-height: 1; transition: color var(--transition);
}
.module:hover .num { color: var(--accent-soft); }
.module .kind {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent);
}
.module h2 { font-family: var(--display); font-weight: 600; font-size: 1.85rem; letter-spacing: -.01em; margin: 12px 0 8px; }
.module p { color: var(--text-dim); margin: 0 0 18px; max-width: 40ch; }
.module .specs { list-style: none; margin: 0 0 22px; padding: 0; }
.module .specs li {
  font-family: var(--mono); font-size: .8rem; color: var(--text-dim);
  padding: 5px 0; border-top: 1px dashed var(--border); display: flex; gap: 10px;
}
.module .specs li::before { content: '→'; color: var(--accent); }
.module .open {
  font-family: var(--mono); font-size: .82rem; letter-spacing: .04em;
  color: var(--text); display: inline-flex; align-items: center; gap: 8px;
}
.module .open .arrow { transition: transform var(--transition); }
.module:hover .open .arrow { transform: translateX(5px); }

/* spec strip */
.specstrip {
  margin-top: 18px; display: grid; grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
@media (max-width: 760px) { .specstrip { grid-template-columns: 1fr 1fr; } }
.specstrip div {
  padding: 16px 18px; border-right: 1px solid var(--border); background: var(--surface);
}
.specstrip div:last-child { border-right: none; }
.specstrip b { display: block; font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 5px; }
.specstrip span { font-size: .86rem; color: var(--text-dim); }

/* ------------------------------------------------------------ module shell */
.module-head { margin-bottom: 24px; }
.module-head .index {
  font-family: var(--mono); font-size: .76rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 8px;
}
.module-head h2 { font-family: var(--display); font-weight: 600; font-size: clamp(1.7rem, 3.4vw, 2.4rem); letter-spacing: -.01em; margin: 0 0 6px; }
.module-head p { color: var(--text-dim); margin: 0; max-width: 60ch; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 372px);
  gap: 22px;
  align-items: start;
}
@media (max-width: 920px) { .workspace { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.panel + .panel { margin-top: 18px; }
.panel h3 {
  margin: 0 0 16px;
  font-family: var(--mono);
  font-size: .76rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 9px;
}
.panel h3::before { content: ''; width: 7px; height: 7px; background: var(--accent); border-radius: 1px; }

/* ----------------------------------------------------------- form controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint);
}
select {
  appearance: none;
  font-family: var(--font); font-size: .9rem; color: var(--text);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a9099' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 32px 9px 12px;
  cursor: pointer;
  min-width: 138px;
  transition: var(--transition);
}
select:hover { border-color: var(--border-strong); }
select:focus-visible, .btn:focus-visible, .nav-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  font-family: var(--mono); font-weight: 500; font-size: .84rem;
  letter-spacing: .01em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 15px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn--ghost { background: none; }
.btn--lg { padding: 12px 20px; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.btn-row--sep { margin-top: 14px; padding-top: 16px; border-top: 1px dashed var(--border); }

input[type='range'] {
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 99px; background: var(--border-strong); width: 128px; cursor: pointer;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 2px;
  background: var(--accent); border: none; cursor: pointer;
}
input[type='range']::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 2px; background: var(--accent); border: none;
}

.status {
  margin: 0; font-family: var(--mono); font-weight: 500; font-size: .9rem;
  color: var(--text-dim); min-height: 1.4em;
}
.status--good { color: var(--good); }
.status--bad { color: var(--bad); }
.step-info { font-family: var(--mono); font-size: .78rem; color: var(--text-faint); margin-left: auto; }

.footer {
  max-width: var(--maxw); margin: 0 auto;
  padding: 40px clamp(22px, 4vw, 52px) 32px;
  border-top: 1px solid var(--border);
  color: var(--text-faint); font-family: var(--mono); font-size: .76rem; letter-spacing: .04em;
}
.footer code { color: var(--text-dim); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (prefers-reduced-motion: reduce) {
  .view--active .stagger > * { animation: none; opacity: 1; }
}
