/* Thought Leap — Calibration Atelier */
:root {
  --paper: #F2EEE6;
  --paper-deep: #E9E3D6;
  --ink: #181611;
  --ink-soft: #5C5852;
  --ink-faint: #ABA398;
  --hairline: rgba(24, 22, 17, 0.16);
  --accent: #E8501F;
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'Instrument Sans', system-ui, sans-serif;
  --mono: 'Spline Sans Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
}

#root { height: 100dvh; display: flex; flex-direction: column; }

/* grain */
.tl-grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 60; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ——— chrome ——— */
.tl-chrome {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 14px; gap: 16px; flex-shrink: 0;
}
.tl-wordmark { font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
.tl-wordmark em { font-style: normal; color: var(--accent); }
.tl-phase-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; }

.tl-progress { display: flex; gap: 6px; flex: 1; max-width: 280px; }
.tl-progress span { height: 2px; flex: 1; background: var(--hairline); position: relative; overflow: hidden; }
.tl-progress span i { position: absolute; inset: 0; background: var(--ink); transform-origin: left; transform: scaleX(0); transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1); display: block; }

.tl-stage { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }

/* ——— shared type ——— */
.tl-kicker { font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent); }
.tl-display { font-family: var(--serif); font-weight: 400; line-height: 1.04; letter-spacing: -0.01em; text-wrap: pretty; margin: 0; }
.tl-display em { font-style: italic; }
.tl-sub { color: var(--ink-soft); font-size: 16px; max-width: 44ch; text-wrap: pretty; }

/* ——— buttons ——— */
.tl-btn {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  padding: 14px 28px; cursor: pointer; border-radius: 999px;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px;
}
.tl-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; transform: translateY(-1px); }
.tl-btn:active { transform: translateY(0px) scale(0.98); }
.tl-btn.ghost { background: transparent; color: var(--ink); }
.tl-btn.ghost:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tl-btn.quiet { background: transparent; border-color: transparent; color: var(--ink-soft); }
.tl-btn.quiet:hover { color: var(--ink); background: transparent; transform: none; }
.tl-btn:disabled { opacity: 0.35; pointer-events: none; }

/* ——— welcome ——— */
.tl-welcome { flex: 1; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.tl-welcome-inner { display: flex; flex-direction: column; gap: 28px; max-width: 620px; width: 100%; align-items: flex-start; }
.tl-input-row { width: 100%; border-bottom: 1px solid var(--ink); display: flex; align-items: baseline; gap: 12px; }
.tl-input {
  font-family: var(--serif); font-size: clamp(28px, 6vw, 44px); border: none; background: transparent;
  color: var(--ink); width: 100%; padding: 6px 0 10px; outline: none;
}
.tl-input::placeholder { color: var(--ink-faint); }
.tl-field-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-soft); }

/* ——— swipe deck ——— */
.tl-swipe-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 14px 16px 20px; min-height: 0; }
.tl-deck { position: relative; flex: 1; width: min(380px, 92vw); min-height: 0; touch-action: none; }
.tl-card {
  position: absolute; inset: 0; border-radius: 18px; overflow: hidden;
  border: 1px solid rgba(24,22,17,0.2);
  box-shadow: 0 24px 48px -24px rgba(24,22,17,0.35);
  display: flex; flex-direction: column; user-select: none; -webkit-user-select: none;
  will-change: transform; cursor: grab;
}
.tl-card:active { cursor: grabbing; }
.tl-card-stamp {
  position: absolute; top: 26px; font-family: var(--mono); font-size: 13px; letter-spacing: 0.2em;
  text-transform: uppercase; padding: 8px 14px; border: 2px solid currentColor; border-radius: 8px;
  opacity: 0; pointer-events: none; z-index: 3; background: rgba(255,255,255,0.08); backdrop-filter: blur(2px);
}
.tl-stamp-yes { left: 22px; transform: rotate(-9deg); }
.tl-stamp-no { right: 22px; transform: rotate(9deg); }
.tl-swipe-actions { display: flex; gap: 14px; align-items: center; padding-top: 18px; }
.tl-round-btn {
  width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--ink);
  background: transparent; color: var(--ink); cursor: pointer; font-size: 20px;
  display: grid; place-items: center; transition: transform 0.15s ease, background 0.2s, color 0.2s;
}
.tl-round-btn:hover { transform: translateY(-2px) scale(1.05); }
.tl-round-btn.yes:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.tl-round-btn.no:hover { background: var(--ink); color: var(--paper); }
.tl-deck-counter { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; color: var(--ink-soft); white-space: nowrap; }

/* ——— calibration (sliders) ——— */
.tl-cal { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 20px 20px; align-items: center; }
.tl-specimen-frame {
  flex: 1; width: min(560px, 100%); min-height: 0; border-radius: 20px; overflow: hidden;
  border: 1px solid rgba(24,22,17,0.2); position: relative;
  box-shadow: 0 24px 48px -28px rgba(24,22,17,0.3);
}
.tl-cal-controls { width: min(560px, 100%); padding-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.tl-axis-labels { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.tl-axis-end { font-family: var(--mono); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; transition: color 0.2s, opacity 0.2s; }
.tl-axis-hint { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--ink-soft); }

.tl-slider { position: relative; height: 48px; display: flex; align-items: center; touch-action: none; cursor: ew-resize; }
.tl-slider-track { position: absolute; left: 0; right: 0; height: 2px; background: var(--hairline); }
.tl-slider-ticks { position: absolute; left: 0; right: 0; height: 100%; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.tl-slider-ticks i { width: 1px; height: 10px; background: var(--hairline); display: block; }
.tl-slider-ticks i:nth-child(5) { height: 18px; background: var(--ink-faint); }
.tl-thumb {
  position: absolute; top: 50%; width: 30px; height: 30px; border-radius: 50%;
  background: var(--ink); border: 6px solid var(--paper); outline: 1px solid var(--ink);
  transform: translate(-50%, -50%); box-shadow: 0 6px 14px -4px rgba(24,22,17,0.5);
  transition: background 0.2s;
}
.tl-slider.active .tl-thumb { background: var(--accent); outline-color: var(--accent); }

/* ——— duels ——— */
.tl-duel { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 20px 24px; align-items: center; }
.tl-duel-grid { flex: 1; width: min(720px, 100%); min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 540px) { .tl-duel-grid { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; } }
.tl-duel-option {
  border: 1px solid rgba(24,22,17,0.25); border-radius: 18px; overflow: hidden; cursor: pointer;
  position: relative; display: flex; flex-direction: column; background: #FBF9F4;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; min-height: 0;
}
.tl-duel-option:hover { transform: translateY(-3px); box-shadow: 0 18px 36px -20px rgba(24,22,17,0.4); border-color: var(--ink); }
.tl-duel-option:active { transform: scale(0.985); }
.tl-duel-name {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  padding: 12px 16px; border-top: 1px solid rgba(24,22,17,0.15); color: var(--ink-soft);
  display: flex; justify-content: space-between; align-items: center;
}
.tl-duel-canvas { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; }

/* ——— words ——— */
.tl-words { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 20px 24px; align-items: center; overflow-y: auto; }
.tl-word-cloud { width: min(680px, 100%); display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 10px 0 18px; }
.tl-word {
  font-family: var(--serif); font-size: clamp(18px, 2.6vw, 24px); padding: 10px 20px; border-radius: 999px;
  border: 1px solid var(--hairline); background: transparent; color: var(--ink); cursor: pointer;
  transition: all 0.18s ease; min-height: 44px;
}
.tl-word:hover { border-color: var(--ink); transform: translateY(-1px); }
.tl-word.on { background: var(--ink); color: var(--paper); border-color: var(--ink); font-style: italic; }
.tl-word:disabled { opacity: 0.35; cursor: default; transform: none; }

/* ——— module header ——— */
.tl-module-head { text-align: center; padding: 6px 20px 18px; display: flex; flex-direction: column; gap: 8px; align-items: center; flex-shrink: 0; }
.tl-module-head .tl-kicker { white-space: nowrap; }
.tl-module-head .tl-display { font-size: clamp(24px, 4vw, 36px); line-height: 1.14; }

/* ——— footer nav ——— */
.tl-foot { display: flex; justify-content: center; gap: 10px; padding: 14px 20px 20px; flex-shrink: 0; }

/* ——— reveal ——— */
.tl-reveal { flex: 1; overflow-y: auto; padding: 12px 20px 60px; }
.tl-reveal-inner { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 36px; }
.tl-reveal-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 28px 0 8px; }
.tl-reveal-hero .tl-display { font-size: clamp(42px, 9vw, 84px); }
.tl-essence { font-family: var(--serif); font-size: clamp(19px, 3vw, 24px); font-style: italic; color: var(--ink); max-width: 36ch; text-wrap: pretty; line-height: 1.35; margin: 0; }
.tl-section-title { font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-soft); border-bottom: 1px solid var(--hairline); padding-bottom: 10px; margin-bottom: 18px; display: flex; justify-content: space-between; }

.tl-coords { display: flex; flex-direction: column; gap: 16px; }
.tl-coord-row { display: grid; grid-template-columns: 92px 1fr 92px; gap: 12px; align-items: center; }
@media (max-width: 540px) { .tl-coord-row { grid-template-columns: 72px 1fr 72px; } }
.tl-coord-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.tl-coord-label.r { text-align: right; }
.tl-coord-track { position: relative; height: 2px; background: var(--hairline); }
.tl-coord-track::before { content: ''; position: absolute; left: 50%; top: -5px; width: 1px; height: 12px; background: var(--ink-faint); }
.tl-coord-dot {
  position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  transform: translate(-50%, -50%); box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px var(--accent);
}
.tl-anim-ok .tl-coord-dot { transition: left 1s cubic-bezier(0.22, 1, 0.36, 1); }

.tl-palette-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tl-swatch { border-radius: 12px; border: 1px solid rgba(24,22,17,0.18); aspect-ratio: 1 / 1.1; position: relative; overflow: hidden; }
.tl-swatch span { position: absolute; left: 10px; bottom: 8px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; mix-blend-mode: difference; color: #fff; }

.tl-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 540px) { .tl-board { grid-template-columns: repeat(2, 1fr); } }
.tl-board-tile { border-radius: 14px; overflow: hidden; border: 1px solid rgba(24,22,17,0.18); aspect-ratio: 1; position: relative; }

/* ——— specimen triptych ——— */
.tl-triptych { display: flex; flex-direction: column; gap: 18px; }
.tl-trip-frame {
  position: relative; height: clamp(170px, 26vw, 215px); border-radius: 16px; overflow: hidden;
  border: 1px solid rgba(24,22,17,0.2); box-shadow: 0 18px 36px -26px rgba(24,22,17,0.3);
}
.tl-trip-caption {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 2px 0;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-soft);
}

/* ——— the read ——— */
.tl-read { font-family: var(--serif); font-size: clamp(18px, 2.8vw, 22px); line-height: 1.55; margin: 0; text-wrap: pretty; }
.tl-read em { font-style: italic; }
.tl-tension { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 10px; }
.tl-tension p { font-family: var(--serif); font-style: italic; font-size: clamp(17px, 2.6vw, 20px); line-height: 1.5; margin: 0; color: var(--ink); text-wrap: pretty; }

.tl-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tl-chip { font-family: var(--serif); font-style: italic; font-size: 18px; border: 1px solid var(--hairline); padding: 6px 16px; border-radius: 999px; }

.tl-reveal-cta { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 18px 0; border-top: 1px solid var(--hairline); }

/* ——— specimen brief poster (offscreen export node) ——— */
.tl-poster {
  position: fixed; left: -10000px; top: 0; width: 540px; height: 675px;
  background: var(--paper); color: var(--ink); overflow: hidden;
  display: flex; flex-direction: column; gap: 16px; padding: 26px;
}
.tl-poster-head { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em; }
.tl-poster-head em { font-style: normal; color: var(--accent); }
.tl-poster-plate { position: relative; height: 300px; border-radius: 14px; overflow: hidden; border: 1px solid rgba(24,22,17,0.25); flex-shrink: 0; }
.tl-poster-kicker { font-family: var(--mono); font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent); }
.tl-poster-arch h2 { font-family: var(--serif); font-size: 38px; line-height: 1.02; margin: 2px 0 0; font-weight: 400; }
.tl-poster-spine { display: flex; flex-direction: column; gap: 9px; }
.tl-poster-srow { display: grid; grid-template-columns: 62px 1fr 62px; gap: 10px; align-items: center; font-family: var(--mono); font-size: 7.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.tl-poster-srow .r { text-align: right; }
.tl-poster-track { position: relative; height: 1px; background: var(--hairline); display: block; }
.tl-poster-dot { position: absolute; top: 50%; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); transform: translate(-50%, -50%); }
.tl-poster-bottom { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.tl-poster-pal { display: flex; gap: 6px; }
.tl-poster-pal span { width: 24px; height: 24px; border-radius: 6px; border: 1px solid rgba(24,22,17,0.2); display: block; }
.tl-poster-words { font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--ink-soft); text-align: right; }
.tl-poster-foot { margin-top: auto; padding-top: 11px; border-top: 1px solid var(--hairline); display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.tl-poster-foot em { font-style: normal; color: var(--accent); }
.tl-poster-grain { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.5; pointer-events: none; }
.tl-link-fallback {
  font-family: var(--mono); font-size: 11px; color: var(--ink-soft); word-break: break-all;
  max-width: 56ch; border: 1px solid var(--hairline); border-radius: 10px; padding: 8px 12px; user-select: all;
}

/* ——— entrances ——— */
/* .tl-anim-ok is added by a runtime check that the animation clock is live */
@media (prefers-reduced-motion: no-preference) {
  .tl-anim-ok .tl-rise { animation: tlRise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
  .tl-anim-ok .tl-rise-2 { animation: tlRise 0.6s 0.08s cubic-bezier(0.22, 1, 0.36, 1) both; }
  .tl-anim-ok .tl-rise-3 { animation: tlRise 0.6s 0.16s cubic-bezier(0.22, 1, 0.36, 1) both; }
  .tl-anim-ok .tl-rise-4 { animation: tlRise 0.6s 0.24s cubic-bezier(0.22, 1, 0.36, 1) both; }
  @keyframes tlRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
}
