/* ============================================================
   simai.bar -- Bauhaus laboratory manifesto, HUD overlay
   Strict 5-color palette + pencil graphite
   ============================================================ */

:root {
  --bh-red:    #d62828;
  --bh-yellow: #fcbf49;
  --bh-blue:   #003049;
  --ink:       #1a1a1a;
  --paper:     #f4ead5;
  --graphite:  #2b2b2b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  position: relative;
}

/* ---- Paper noise overlay ---- */
.paper-noise {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.1  0 0 0 0 0.1  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.6'/></svg>");
  opacity: 0.04;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: multiply;
}

/* ============================================================
   CONSTRUCTIVIST DIAGONALS  (confidence interval rails)
   ============================================================ */
.diagonals {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}
.diag {
  position: absolute;
  top: 50%;
  left: -50%;
  width: 200%;
  height: 4px;
  background: var(--ink);
  transform-origin: center center;
  opacity: 0.95;
}
.diag-30   { transform: translate(0, -60vh) rotate(30deg); }
.diag-60   { transform: translate(0, -10vh) rotate(60deg); }
.diag-neg45{ transform: translate(0, 40vh)  rotate(-45deg); }
.diag-label {
  position: absolute;
  right: 28%;
  top: -1.8rem;
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  color: var(--graphite);
  opacity: 0.7;
  transform: rotate(-30deg);
  background: var(--paper);
  padding: 0 0.3rem;
}
.diag-60 .diag-label  { transform: rotate(-60deg); }
.diag-neg45 .diag-label{ transform: rotate(45deg); right: 22%; }

/* ============================================================
   MASTHEAD
   ============================================================ */
.masthead {
  position: relative;
  height: 18vh;
  min-height: 140px;
  border-bottom: 4px solid var(--ink);
  padding: 1vh 4vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 4;
  background: var(--paper);
}

.wordmark {
  font-family: 'Archivo Black', sans-serif;
  font-weight: 900;
  font-size: clamp(3.2rem, 11vw, 8rem);
  letter-spacing: -0.04em;
  line-height: 0.85;
  color: var(--ink);
  white-space: nowrap;
  position: relative;
  display: inline-flex;
  align-items: baseline;
}

.wm-prefix, .wm-i, .wm-period, .wm-r {
  display: inline-block;
}

/* Dot of the "i" -- absolute red circle, pulsing */
.wm-i {
  position: relative;
}
.wm-i-dot {
  position: absolute;
  top: -0.05em;
  left: 50%;
  transform: translateX(-50%);
  width: 0.4em;
  height: 0.4em;
  background: var(--bh-red);
  border-radius: 50%;
  animation: pulseDot 1.4s ease-in-out infinite alternate;
}
@keyframes pulseDot {
  0%   { transform: translateX(-50%) scale(1.0); opacity: 1; }
  100% { transform: translateX(-50%) scale(1.18); opacity: 0.75; }
}

/* The "BAR" R -- single gradient cameo */
.wm-r {
  background: linear-gradient(180deg, var(--bh-red) 0%, var(--bh-blue) 50%, var(--bh-yellow) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
  transition: filter 600ms ease;
}
.wm-r.milestone-hit {
  filter: hue-rotate(40deg) saturate(1.4);
}

/* Period -- small red square */
.wm-period {
  position: relative;
  color: transparent;
  width: 0.32em;
}
.wm-period::after {
  content: "";
  position: absolute;
  bottom: 0.12em;
  left: 50%;
  transform: translateX(-50%);
  width: 0.22em;
  height: 0.22em;
  background: var(--bh-red);
}

.masthead-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  text-align: right;
  border-left: 1px solid var(--ink);
  padding-left: 1.2rem;
}
.meta-line {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
}
.meta-label {
  font-family: 'Archivo', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.65rem;
  color: var(--ink);
}
.meta-val {
  color: var(--bh-blue);
  font-weight: 700;
}

/* ============================================================
   NAV RAIL
   ============================================================ */
.nav-rail {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7vh 4vw;
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
  z-index: 4;
}

.nav-items {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  position: relative;
}

.nav-item {
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink);
  text-decoration: none;
  padding: 0.25rem 0;
  cursor: pointer;
  position: relative;
}

.nav-sep {
  color: var(--ink);
  opacity: 0.6;
  font-size: 0.8rem;
}

.nav-underline {
  position: absolute;
  bottom: -0.2rem;
  left: 0;
  height: 4px;
  background: var(--bh-red);
  transition: transform 400ms cubic-bezier(0.7, 0, 0.3, 1), width 400ms cubic-bezier(0.7, 0, 0.3, 1);
  pointer-events: none;
}

.nav-ticker {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  max-width: 50vw;
  overflow: hidden;
}

.ticker-label {
  font-family: 'Archivo', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  padding: 0.15rem 0.4rem;
}

.ticker-text {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  color: var(--ink);
  white-space: nowrap;
}

/* ============================================================
   PLATE GRID
   ============================================================ */
.plate {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(8, 1fr);
  height: calc(100vh - 18vh - 4.2vh - 4px);
  min-height: 580px;
  gap: 0;
  border-top: 4px solid var(--ink);
  background: var(--paper);
  z-index: 3;
}

/* Visible construction lines on every cell */
.plate::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(26,26,26,0.3) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(26,26,26,0.3) 1px, transparent 1px);
  background-size: calc(100% / 12) calc(100% / 8);
  pointer-events: none;
  z-index: 0;
}

/* ---- plate-header band: spans all cols, row 1 ---- */
.plate-header {
  grid-column: 1 / 13;
  grid-row: 1 / 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2vw;
  border-bottom: 1px solid var(--ink);
  background: rgba(244, 234, 213, 0.92);
  z-index: 2;
}
.section-title {
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink);
  display: inline-block;
  border-bottom: 4px solid var(--bh-red);
  padding-bottom: 2px;
}
.header-keys {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
}
.key {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  padding: 0.15rem 0.45rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 1px;
}
.key-label {
  margin-right: 0.5rem;
  letter-spacing: 0.05em;
  color: var(--ink);
}

/* ---- Three primary live shapes ---- */
.shape {
  position: relative;
  z-index: 2;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  border: none;
  background: transparent;
}
.shape svg {
  width: 88%;
  height: 88%;
  overflow: visible;
}
.shape-tag {
  position: absolute;
  bottom: 0.4rem;
  left: 0.6rem;
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink);
  background: var(--paper);
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--ink);
  z-index: 3;
}

.shape-circle   { grid-column: 1 / 5;  grid-row: 2 / 6; }
.shape-triangle { grid-column: 5 / 8;  grid-row: 4 / 9; }
.shape-square   { grid-column: 8 / 13; grid-row: 2 / 5; }

.shape.is-active svg :is(circle, polygon, rect) {
  stroke-width: 5;
}

/* ---- Manifesto block ---- */
.manifesto {
  grid-column: 1 / 5;
  grid-row: 6 / 9;
  padding: 1.2rem 1.4rem;
  background: rgba(244, 234, 213, 0.88);
  border-top: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.manifesto-line {
  font-family: 'Archivo Black', sans-serif;
  font-size: clamp(1rem, 1.6vw, 1.5rem);
  line-height: 1.0;
  letter-spacing: -0.02em;
  margin-bottom: 0.6rem;
  color: var(--ink);
}
.manifesto-body {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 0.6rem;
}
.manifesto-sig {
  font-family: 'Caveat', cursive;
  font-size: 1.1rem;
  color: var(--graphite);
  opacity: 0.8;
  transform: rotate(-2deg);
  align-self: flex-end;
}

/* ---- Distribution card ---- */
.distribution-card {
  grid-column: 8 / 13;
  grid-row: 5 / 9;
  padding: 0.9rem 1.2rem;
  background: rgba(244, 234, 213, 0.88);
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
  z-index: 2;
  display: flex;
  flex-direction: column;
}
.dc-title {
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink);
  border-bottom: 4px solid var(--bh-yellow);
  display: inline-block;
  padding-bottom: 2px;
  margin-bottom: 0.7rem;
  width: max-content;
}
.dc-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Space Mono', monospace;
  font-size: 0.95rem;
}
.dc-table tr {
  border-bottom: 1px solid var(--ink);
}
.dc-table tr:last-child { border-bottom: none; }
.dc-key {
  padding: 0.45rem 0.4rem 0.45rem 0;
  color: var(--ink);
  font-weight: 400;
  width: 40%;
}
.dc-val {
  text-align: right;
  padding: 0.45rem 0 0.45rem 0.4rem;
  color: var(--bh-blue);
  font-weight: 700;
}

/* ---- Footnote ---- */
.footnote {
  grid-column: 1 / 13;
  grid-row: 8 / 9;
  display: none; /* reserved cell, used via background only */
}

/* ============================================================
   HUD CORNERS (mix-blend-mode: difference)
   ============================================================ */
.hud {
  position: fixed;
  padding: 0.55rem 0.9rem;
  mix-blend-mode: difference;
  color: var(--paper);
  font-family: 'Space Mono', monospace;
  border: 1px solid var(--paper);
  pointer-events: auto;
  z-index: 50;
  min-width: 9.5rem;
  transition: transform 200ms ease, padding 200ms ease;
  cursor: default;
}
.hud-tl { top: 1.5vh;  left: 1.5vw; }
.hud-tr { top: 1.5vh;  right: 1.5vw; text-align: right; }
.hud-bl { bottom: 4vh; left: 1.5vw; }
.hud-br { bottom: 4vh; right: 1.5vw; text-align: right; }

.hud-label {
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.2rem;
}
.hud-num {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.hud:hover {
  transform: scale(1.08);
  padding: 0.7rem 1.1rem;
}

/* ============================================================
   KINETIC NUMERALS  (rolling digit animation)
   ============================================================ */
.kinetic {
  display: inline-block;
  overflow: hidden;
  height: 1.25em;
  line-height: 1.25em;
}
.kinetic .digit {
  display: inline-block;
  vertical-align: top;
  width: 0.65em;
  text-align: center;
  position: relative;
}
.kinetic .digit.rolling {
  animation: rollDigit 200ms cubic-bezier(0.7, 0, 0.3, 1);
}
@keyframes rollDigit {
  0%   { transform: translateY(0);       opacity: 1; }
  49%  { transform: translateY(-1.05em); opacity: 0; }
  50%  { transform: translateY(1em);     opacity: 0; }
  100% { transform: translateY(0);       opacity: 1; }
}

/* ============================================================
   PROGRESS TAPE (80 squares)
   ============================================================ */
.progress-tape {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 14px;
  display: flex;
  gap: 2px;
  padding: 3px 1.5vw;
  background: var(--paper);
  border-top: 4px solid var(--ink);
  z-index: 40;
  align-items: center;
}
.progress-tape .pip {
  flex: 1 1 auto;
  height: 8px;
  background: transparent;
  border: 1px solid var(--ink);
}
.progress-tape .pip.filled {
  background: var(--bh-red);
  border-color: var(--bh-red);
}

/* ============================================================
   PENCIL ANNOTATIONS LAYER
   ============================================================ */
.pencil-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
  opacity: 0.85;
}
.pencil-layer .pencil-stroke {
  fill: none;
  stroke: var(--graphite);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
}
.pencil-layer .pencil-arrow {
  fill: var(--graphite);
  stroke: none;
  opacity: 0.7;
}
.pencil-layer .pencil-label {
  font-family: 'Caveat', cursive;
  font-size: 20px;
  fill: var(--graphite);
  opacity: 0.75;
}

/* ============================================================
   PAUSED OVERLAY
   ============================================================ */
.paused-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(244, 234, 213, 0.18);
  z-index: 60;
  pointer-events: none;
}
.paused-overlay.is-shown {
  display: flex;
}
.paused-text {
  font-family: 'Archivo Black', sans-serif;
  font-size: clamp(1.2rem, 3vw, 2.4rem);
  letter-spacing: -0.02em;
  color: var(--ink);
  background: var(--bh-yellow);
  border: 4px solid var(--ink);
  padding: 0.6rem 1.2rem;
  text-transform: uppercase;
  transform: rotate(-1.5deg);
}

/* ============================================================
   RESPONSIVE -- compress shapes on narrow screens but keep grid
   ============================================================ */
@media (max-width: 880px) {
  .masthead { height: auto; padding: 1.2vh 4vw 2vh; flex-direction: column; align-items: flex-start; gap: 0.8rem; }
  .masthead-meta { border-left: none; padding-left: 0; flex-direction: row; gap: 1rem; }
  .meta-line { gap: 0.5rem; }
  .nav-rail { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .nav-ticker { max-width: 100vw; }
  .plate {
    height: auto;
    min-height: 700px;
    grid-template-rows: auto repeat(7, minmax(80px, 1fr));
  }
  .shape-circle   { grid-column: 1 / 7;  grid-row: 2 / 5; }
  .shape-triangle { grid-column: 7 / 13; grid-row: 2 / 5; }
  .shape-square   { grid-column: 1 / 13; grid-row: 5 / 7; }
  .manifesto      { grid-column: 1 / 13; grid-row: 7 / 8; }
  .distribution-card { grid-column: 1 / 13; grid-row: 8 / 9; }
  .hud { font-size: 0.85rem; min-width: 8rem; padding: 0.4rem 0.7rem; }
  .hud-num { font-size: 0.95rem; }
}
