/* MEKU SI — PROJECT MANIFEST: THE FORGE OF TOMORROW
 * Dark obsidian spatial layout with controlled MEKU orange (#FF6000).
 * Accessible keyboard focus, 320px mobile support, reduced-motion & print-sigil support.
 * ZERO music, ZERO strobing, ZERO hidden tracking.
 */

:root {
  --bg: #070706;
  --bg-elev: #0f0d0c;
  --panel: rgba(15, 13, 12, 0.88);
  --panel-soft: rgba(24, 20, 18, 0.65);
  --orange: #ff6000;
  --orange-soft: #ff944d;
  --orange-dim: rgba(255, 96, 0, 0.22);
  --cream: #f0eae0;
  --muted: #a39a91;
  --line: rgba(240, 234, 224, 0.16);
  --line-strong: rgba(255, 96, 0, 0.45);
  --danger: #ff4f3a;
  --ok: #e9a354;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: dark;
}

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

html {
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font);
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 0%, #1a0f09 0%, #070706 58%);
  color: var(--cream);
  line-height: 1.55;
  overflow-x: clip;
}

.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;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--orange);
  color: #070706;
  padding: 10px 14px;
  font-weight: 700;
  z-index: 999;
}
.skip-link:focus { left: 8px; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  min-height: 42px;
  border-radius: 2px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 clamp(12px, 3.2vw, 44px) 56px;
}

/* Header */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(255, 96, 0, 0.5);
  background: var(--orange);
  display: block;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand-title strong {
  display: block;
  font-size: 16px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.brand-title strong span { color: var(--orange); }
.brand-title small {
  display: block;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
}

.top-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--cream);
  padding: 8px 13px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: border-color 0.16s, background 0.16s;
}
.btn:hover:not(:disabled) {
  border-color: var(--orange);
  background: rgba(255, 96, 0, 0.14);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  border-color: var(--orange);
  background: rgba(255, 96, 0, 0.18);
  color: #fff6ee;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: rgba(255, 96, 0, 0.34);
}
.btn-active,
.btn[aria-pressed="true"] {
  border-color: var(--orange);
  background: rgba(255, 96, 0, 0.22);
  color: #fff3e6;
}
.btn-stop {
  border: 1px solid var(--orange);
  background: rgba(255, 96, 0, 0.12);
  color: var(--orange-soft);
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 8px 16px;
}
.btn-stop:hover {
  background: rgba(255, 79, 58, 0.28);
  border-color: var(--danger);
  color: #ffffff;
}
.btn-danger {
  border-color: rgba(255, 79, 58, 0.6);
  color: #ffb1a6;
}
.btn-danger:hover:not(:disabled) {
  background: rgba(255, 79, 58, 0.22);
  border-color: var(--danger);
}

/* Hero & Contract Banner */
.hero {
  padding: 26px 0 18px;
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--orange);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.hero h1 {
  margin: 0;
  font-size: clamp(32px, 5.4vw, 64px);
  line-height: 0.98;
  letter-spacing: -0.02em;
  font-weight: 600;
}
.hero h1 em {
  color: var(--orange);
  font-style: normal;
}
.contract-quote {
  margin: 12px 0 10px;
  font-size: clamp(16px, 2.1vw, 21px);
  color: var(--cream);
  border-left: 3px solid var(--orange);
  padding-left: 14px;
}
.hero-sub {
  margin: 0;
  max-width: 76ch;
  font-size: 14px;
  color: var(--muted);
}

/* Three Truths Strip (Never collapsed into one badge) */
.truths-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.truth-cell {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 10px 12px;
}
.truth-cell strong {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--orange);
}
.truth-cell span {
  display: block;
  font-size: 13px;
  color: var(--cream);
  margin-top: 3px;
  overflow-wrap: anywhere;
}
.truth-cell small {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

/* Ten-Lantern Ceremony Strip */
.ceremony-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px;
  margin-bottom: 16px;
}
.ceremony-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.ceremony-head strong { color: var(--cream); }
.lantern-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lantern {
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}
.lantern.active {
  border-color: var(--orange);
  color: #fff;
  background: rgba(255, 96, 0, 0.24);
}
.lantern.done {
  border-color: rgba(255, 148, 77, 0.45);
  color: var(--orange-soft);
}
.ceremony-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* Chamber Navigation & Forge Stage Layout */
.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.chamber-nav {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 10px;
}
.chamber-nav-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--orange);
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.chamber-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chamber-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 10px;
  font-size: 13px;
  color: #d6cfc7;
}
.chamber-btn:hover {
  border-color: rgba(255, 96, 0, 0.4);
  background: rgba(255, 96, 0, 0.08);
}
.chamber-btn.active {
  border-color: var(--orange);
  background: rgba(255, 96, 0, 0.16);
  color: #ffffff;
}
.chamber-btn .c-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--orange);
  margin-right: 6px;
}
.chamber-btn .c-stage {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

/* Main Stage */
.stage-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.scene-frame {
  position: relative;
  border: 1px solid var(--line-strong);
  background: #070706;
  overflow: hidden;
}
#forgeCanvas {
  display: block;
  width: 100%;
  height: 240px;
}
.scene-caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: rgba(7, 7, 6, 0.92);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.scene-caption strong { color: var(--orange-soft); }

.chamber-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: clamp(14px, 2.2vw, 24px);
}
.chamber-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.chamber-header h2 {
  margin: 0;
  font-size: clamp(20px, 2.6vw, 28px);
  font-weight: 600;
}
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  color: var(--orange-soft);
  text-transform: uppercase;
}
.badge-muted {
  border-color: var(--line);
  color: var(--muted);
}
.badge-danger {
  border-color: var(--danger);
  color: #ffb1a6;
}

/* Forms & Controls inside chambers */
label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--cream);
}

textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  background: #0a0908;
  border: 1px solid var(--line);
  padding: 10px 12px;
  color: var(--cream);
  border-radius: 2px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.card-box {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  padding: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.card-box h3, .card-box h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--orange-soft);
}
.card-box p {
  margin: 6px 0;
  font-size: 13px;
  color: #d6cfc7;
}

.mono-box {
  font-family: var(--mono);
  font-size: 11px;
  background: #050504;
  border: 1px solid var(--line);
  padding: 10px;
  overflow-x: auto;
  word-break: break-all;
  color: #dfd5c8;
}

.notice {
  border-left: 3px solid var(--orange);
  background: rgba(255, 96, 0, 0.07);
  padding: 10px 12px;
  font-size: 13px;
  margin: 12px 0;
  color: #efe5d8;
}
.notice-danger {
  border-left-color: var(--danger);
  background: rgba(255, 79, 58, 0.12);
}

.sigil-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}
.sigil-preview {
  width: 260px;
  max-width: 100%;
  border: 1px solid var(--line-strong);
  background: #08090c;
}
.sigil-preview svg {
  display: block;
  width: 100%;
  height: auto;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.check-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  background: #0a0908;
}
.check-pill.pass { border-color: var(--orange); color: #fff0e2; }
.check-pill.fail { border-color: rgba(255, 79, 58, 0.6); color: #ffb5ab; }

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.timeline-item {
  border: 1px solid var(--line);
  border-left: 3px solid var(--orange);
  background: #0a0908;
  padding: 10px 12px;
  font-size: 12px;
}
.timeline-item.simulated {
  border-left-style: dashed;
  border-left-color: #c9a787;
}

/* Modals (STOP, History Room, Erase Confirm) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 3, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}
.overlay.hidden { display: none; }
.modal {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #0d0b0a;
  border: 1px solid var(--orange);
  padding: 22px;
}
.modal h2 { margin-top: 0; color: var(--orange-soft); }
.modal a { color: var(--orange-soft); }

.footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  background: #140f0c;
  border: 1px solid var(--orange);
  color: var(--cream);
  padding: 10px 14px;
  font-size: 13px;
  z-index: 250;
}
.toast.hidden { display: none; }

/* Responsive: Clean down to 320px width with zero horizontal overflow */
@media (max-width: 920px) {
  .workspace { grid-template-columns: 1fr; }
  .chamber-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 6px;
  }
  .truths-strip { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .shell { padding: 0 10px 44px; }
  .chamber-list { grid-template-columns: 1fr; }
  .btn { padding: 8px 10px; font-size: 11px; }
  #forgeCanvas { height: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

html[data-reduced-motion="true"],
html.reduced-motion {
  scroll-behavior: auto;
}
html[data-reduced-motion="true"] *,
html[data-reduced-motion="true"] *::before,
html[data-reduced-motion="true"] *::after,
html.reduced-motion *,
html.reduced-motion *::before,
html.reduced-motion *::after {
  transition: none !important;
  animation: none !important;
}

@media print {
  body { background: #ffffff; color: #111111; }
  .topbar, .ceremony-strip, .chamber-nav, .scene-frame, .footer, .toast, .no-print { display: none !important; }
  .chamber-panel { border: none; background: #ffffff; color: #111111; }
}
