/* ===========================================================================
   ASPECT — Swiss / International Typographic system.
   border-radius:0, zero gradients, zero shadows. Solid 1px charcoal rules.
   Abstract Elegance: living texture, poetic transitions, architectural typography.
   =========================================================================== */

:root {
  --signal: #ECC822;      /* Signal Yellow — canvas + drop zones + attribution */
  --charcoal: #121212;    /* Deep Charcoal — type + structural rules */
  --noir: #0A0A0A;        /* Code Surface Noir — editor surfaces only */
  --white: #FFFFFF;       /* Stark White — previews + syntax tokens */
  --rule: 2px;            /* the unyielding structural line */
  --stamp: 11px;
  --display: 'Neue Haas Grotesk Display Pro', 'Neue Haas Grotesk Display', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; border-radius: 0 !important; }

html { -webkit-font-smoothing: antialiased; text-rendering: geometricPrecision; }

body {
  background: var(--signal);
  color: var(--charcoal);
  font-family: var(--display);
  letter-spacing: -0.02em;
  overflow: hidden;
  min-height: 100vh;
}

/* Living texture: subtle shifting grain that breathes */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  opacity: 0.03;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 8s steps(10) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-1%, -1%); }
  20% { transform: translate(1%, 1%); }
  30% { transform: translate(-1%, 1%); }
  40% { transform: translate(1%, -1%); }
  50% { transform: translate(-1%, 0); }
  60% { transform: translate(1%, 0); }
  70% { transform: translate(0, 1%); }
  80% { transform: translate(0, -1%); }
  90% { transform: translate(1%, 1%); }
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: none; background: none; border: none; color: inherit; }
::selection { background: var(--charcoal); color: var(--signal); }

.mono { font-family: var(--mono); letter-spacing: 0; }
.up { text-transform: uppercase; }

/* ===========================  THE FRAME (gallery margins)  ================= */
.frame {
  position: fixed;
  inset: 0;
  padding: clamp(14px, 2.2vw, 34px);
  display: flex;
  flex-direction: column;
}

/* Outer margin stamps — top register */
.register {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  column-gap: 12px;
  padding-bottom: clamp(8px, 1.2vw, 14px);
}

.register__meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-transform: uppercase;
  opacity: 0.6;
}
.register__meta--right { text-align: right; }
.register__meta b { font-weight: 600; }
.register__meta .dim { opacity: 0.4; }

/* ===========================  KINETIC TRUNCATION LOGO  ===================== */
.logo {
  justify-self: center;
  text-align: center;
  line-height: 0.82;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.04em;
  user-select: none;
  cursor: none;
  position: relative;
  opacity: 0.9;
}
.logo__l1 { font-size: clamp(30px, 4.8vw, 68px); overflow: hidden; height: 0.62em; }
.logo__l2 { font-size: clamp(20px, 3vw, 40px); margin-top: -0.03em; }
.logo__l3 {
  display: flex; align-items: baseline; justify-content: center; gap: 0.4em;
  font-size: clamp(12px, 1.8vw, 22px); margin-top: -0.01em;
}
.logo__vb { font-family: var(--mono); font-size: 0.42em; font-weight: 400; letter-spacing: 0; opacity: 0.5; }
.logo .node { opacity: 0; transition: opacity 0.4s cubic-bezier(.2,.7,.2,1); }
.logo:hover .node { opacity: 1; }

/* ===========================  THE STAGE (split-screen grid)  ============== */
.stage {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--charcoal);
  display: grid;
  grid-template-columns: 1fr 0.92fr 1fr;
  background: var(--charcoal);
  gap: 1px;
}

.panel {
  background: var(--signal);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--charcoal);
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  flex: 0 0 auto;
  opacity: 0.7;
}
.panel__head .idx { font-family: var(--mono); font-weight: 400; opacity: 0.3; letter-spacing: 0; }
.panel__body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

/* ---- INPUT (left): dimension fields ---- */
.input-group { margin-bottom: 20px; }
.input-label {
  display: block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 8px; opacity: 0.5;
}
.dimension-input {
  width: 100%; padding: 12px 14px;
  background: var(--noir); color: var(--white);
  font-family: var(--mono); font-size: 14px; letter-spacing: 0;
  border: 1px solid var(--charcoal); outline: none;
  transition: border-color 0.3s ease;
}
.dimension-input:focus { border-color: var(--signal); }
.dimension-input::placeholder { color: #4c4c46; }

.code {
  flex: 1; min-height: 0; width: 100%;
  background: var(--noir); color: #D7D3C4;
  font-family: var(--mono); font-size: 12px; line-height: 1.65; letter-spacing: 0;
  border: none; outline: none; resize: none; padding: 14px 16px;
  white-space: pre; overflow: auto; tab-size: 2;
  cursor: text;
}
.code::placeholder { color: #4c4c46; }
.code.is-out { color: var(--white); }

/* ---- CENTER: live canvas + ratio display ---- */
.center { background: var(--signal); }
.canvas-wrapper {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--white);
  position: relative; overflow: hidden;
  padding: 24px;
}
.canvas-box {
  background: var(--charcoal);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: all 0.6s cubic-bezier(.2,.7,.2,1);
  max-width: 100%; max-height: 100%;
}
.canvas-label {
  font-family: var(--mono); font-size: clamp(12px, 1.8vw, 18px);
  color: var(--signal); letter-spacing: 0.06em; text-transform: uppercase;
  font-weight: 600;
}

.metrics {
  flex: 0 0 auto;
  border-top: 1px solid var(--charcoal);
  padding: 16px 18px 18px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.ratio-display { text-align: center; }
.ratio-main {
  font-size: clamp(32px, 5vw, 64px); font-weight: 900; letter-spacing: -0.04em;
  line-height: 0.9; color: var(--charcoal);
  transition: all 0.4s cubic-bezier(.2,.7,.2,1);
}
.ratio-decimal {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em;
  margin-top: 6px; opacity: 0.5; text-transform: uppercase;
}

.run {
  margin: 0; flex: 0 0 auto;
  width: 100%; padding: 14px;
  background: var(--charcoal); color: var(--signal);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; font-size: 13px;
  border-top: 1px solid var(--charcoal);
  transition: all 0.4s cubic-bezier(.2,.7,.2,1);
}
.run:hover { background: var(--noir); letter-spacing: 0.08em; }
.run:disabled { opacity: 0.3; }

/* ---- OUTPUT (right): code tabs + export ---- */
.tabs { display: flex; border-bottom: 1px solid var(--charcoal); flex: 0 0 auto; }
.tab {
  flex: 1; padding: 10px 12px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
  border-right: 1px solid var(--charcoal);
  color: var(--charcoal); opacity: 0.4; transition: all 0.4s cubic-bezier(.2,.7,.2,1);
}
.tab:last-child { border-right: none; }
.tab.is-active { opacity: 1; background: var(--charcoal); color: var(--signal); letter-spacing: 0.06em; }

.export-actions { display: flex; border-top: 1px solid var(--charcoal); flex: 0 0 auto; }
.export-actions button {
  flex: 1; padding: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px;
  transition: all 0.4s cubic-bezier(.2,.7,.2,1);
}
.export-actions button:hover { background: var(--charcoal); color: var(--signal); letter-spacing: 0.1em; }
.export-actions button.copied { background: var(--charcoal); color: var(--signal); }

/* ===========================  PROOF-SLIP HISTORY RAIL  ==================== */
.rail {
  flex: 0 0 auto;
  margin-top: clamp(6px, 1vw, 10px);
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em;
  min-height: 18px;
  opacity: 0.6;
}
.rail__lbl { opacity: 0.4; white-space: nowrap; }
.rail__slips { display: flex; gap: 6px; overflow-x: auto; flex: 1; }
.slip {
  flex: 0 0 auto; padding: 3px 7px;
  border: 1px solid var(--charcoal);
  cursor: none; white-space: nowrap;
  transition: all 0.4s cubic-bezier(.2,.7,.2,1);
  opacity: 0.5;
}
.slip:hover { background: var(--charcoal); color: var(--signal); opacity: 1; }
.slip .s-pct { opacity: 0.4; margin-left: 4px; }
.rail__clear { opacity: 0.3; cursor: none; transition: opacity 0.3s ease; }
.rail__clear:hover { opacity: 0.7; }

/* ===========================  ATTRIBUTION STAMPS  ======================== */
.attrib {
  flex: 0 0 auto;
  margin-top: clamp(6px, 0.8vw, 10px);
  display: flex; align-items: baseline; justify-content: space-between;
  font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em;
  opacity: 0.5;
}
.attrib a { position: relative; }
.attrib a b { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; }
.attrib a::after {
  content: ''; position: absolute; left: 0; bottom: -2px; width: 0; height: 1px;
  background: var(--charcoal); transition: width 0.5s cubic-bezier(.2,.7,.2,1);
}
.attrib a:hover::after { width: 100%; }
.attrib .legal a { margin-left: 12px; opacity: 0.4; transition: opacity 0.3s ease; }
.attrib .legal a:hover { opacity: 0.8; }

/* ===========================  CUSTOM CURSOR — THE ANCHOR NODE  ============ */
.anchor { position: fixed; top: 0; left: 0; z-index: 9500; pointer-events: none; width: 40px; height: 40px; transform: translate(-50%, -50%); will-change: transform; }
.anchor svg { width: 100%; height: 100%; overflow: visible; }
.anchor .handle { transition: transform 0.18s cubic-bezier(.2,.7,.2,1), opacity 0.18s ease; opacity: 0; }
.anchor.is-active .handle { opacity: 1; }
.anchor .node-sq { fill: none; stroke: var(--charcoal); stroke-width: 2; }
.anchor .cross { stroke: var(--charcoal); stroke-width: 1.5; }
.anchor .hdot { fill: var(--charcoal); }
.anchor.on-dark .node-sq, .anchor.on-dark .cross { stroke: var(--signal); }
.anchor.on-dark .hdot { fill: var(--signal); }
@media (hover: none) { .anchor { display: none !important; } body { cursor: auto; } button, a, .slip, .dropzone, .logo { cursor: pointer; } }

/* ===========================  LOADER — PATH SIMPLIFICATION  ============== */
.loader {
  position: fixed; inset: 0; z-index: 9999; background: var(--signal);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity 0.9s cubic-bezier(.2,.7,.2,1), visibility 0.9s cubic-bezier(.2,.7,.2,1);
}
.loader.done { opacity: 0; visibility: hidden; }
.loader svg { width: min(36vw, 200px); height: min(36vw, 200px); }
.loader .raw { fill: none; stroke: var(--charcoal); stroke-width: 1.5; opacity: 0.22; }
.loader .clean { fill: none; stroke: var(--charcoal); stroke-width: 2.5; stroke-dasharray: 1200; stroke-dashoffset: 1200; }
.loader__count { margin-top: 18px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.6; }
.loader__count b { font-family: var(--display); font-weight: 700; font-size: 14px; }

/* ===========================  TOAST  ===================================== */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--charcoal); color: var(--signal);
  font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 11px 18px; z-index: 9600; opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease;
  border: var(--rule) solid var(--charcoal);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===========================  RESPONSIVE  ================================ */
@media (max-width: 900px) {
  body { overflow: auto; }
  .frame { position: relative; min-height: 100vh; }
  .stage { grid-template-columns: 1fr; }
  .panel { min-height: 60vh; }
  .center { order: -1; }
  .register { grid-template-columns: 1fr; row-gap: 10px; }
  .register__meta--right { text-align: left; }
  .logo { justify-self: start; text-align: left; }
  .logo__l3 { justify-content: flex-start; }
}
@media (max-width: 540px) {
  .attrib { flex-direction: column; gap: 8px; }
  .tab { font-size: 9.5px; padding: 8px 6px; }
}
