/* ==========================================================================
   allocations — Nunito Typography, Fan-Out Transition & Edge-to-Edge Canvas
   ========================================================================== */

:root {
  --bg-page: #ECECED;
  --bg-tile-hover: rgba(255, 255, 255, 0.34);

  --ink: #111113;
  --ink-secondary: #4A4A52;
  --ink-muted: #767680;
  --border-hairline: #CFCFD6;

  --font-sans: "Nunito", "Avenir Next Rounded", -apple-system, BlinkMacSystemFont, sans-serif;
  --header-h: 40px;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-page);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

input {
  background: none;
  border: none;
  outline: none;
  font-family: inherit;
  color: inherit;
}

/* ==========================================================================
   Top Header (Only visible on Tiled Screen)
   ========================================================================== */

.top-header {
  width: 100vw;
  height: var(--header-h);
  padding: 0 16px;
  background-color: var(--bg-page);
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  text-transform: lowercase;
}

.header-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink-secondary);
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--border-hairline);
  background-color: rgba(255, 255, 255, 0.45);
}

/* ==========================================================================
   Stage 1: Blank Screen & Clockwise Box Input Choreography
   ========================================================================== */

.input-stage {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  position: relative;
  cursor: text;
  transition: transform 280ms var(--ease-out-expo), opacity 240ms ease;
}

.input-stage.converging {
  transform: scale(0.75);
  opacity: 0;
}

.hidden-input {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Docked Completed Pairs above the active prompt */
.completed-pairs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
  max-width: 820px;
  margin-bottom: 32px;
}

.completed-pair {
  display: inline-flex;
  align-items: stretch;
  opacity: 0;
  transform: translateY(6px);
  animation: pairDockIn 260ms var(--ease-out-expo) forwards;
}

@keyframes pairDockIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pair-cell {
  padding: 6px 14px;
  font-size: 16px;
  font-weight: 700;
  border: 1.5px solid var(--pair-color, #111113);
  color: var(--ink);
  white-space: nowrap;
}

.pair-cell-pct {
  margin-left: -1.5px;
  font-variant-numeric: tabular-nums;
}

/* Active Choreography Row in Center */
.active-choreography-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  position: relative;
  transition: transform 320ms var(--ease-out-expo);
}

/* Box Entities (Category & Percent) */
.box-entity {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: pre;
  transition: transform 340ms var(--ease-out-expo), margin 340ms var(--ease-out-expo);
}

.category-entity.slid-left {
  transform: translateX(-14px);
}

.percent-entity {
  font-variant-numeric: tabular-nums;
}

.percent-entity.joined {
  transform: translateX(-14px);
  margin-left: -1.5px;
}

.box-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.box-path {
  fill: none;
  stroke: #111113;
  stroke-width: 1.5px;
  stroke-linecap: square;
  stroke-linejoin: miter;
  transition: stroke 300ms ease;
}

/* Live Typing Line */
.typing-line {
  display: inline-flex;
  align-items: baseline;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: pre;
}

.typed-content {
  color: var(--ink);
}

.prompt-placeholder {
  color: var(--ink-muted);
}

.blinking-cursor {
  display: inline-block;
  color: var(--ink);
  line-height: 1;
  margin-left: 2px;
  font-size: 26px;
  animation: cursorBlink 1s infinite steps(1, start);
}

@keyframes cursorBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.shake-error {
  animation: errorShake 240ms ease;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-4px); }
}

/* ==========================================================================
   Stage 2: Zero-Whitespace, Zero-Scroll Equal-Tiled Screen + Fan-Out Motion
   ========================================================================== */

.tiles-stage {
  width: 100vw;
  height: calc(100vh - var(--header-h));
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.tiles-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 0;
}

.chart-tile {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  border-right: 1px solid var(--border-hairline);
  border-bottom: 1px solid var(--border-hairline);
  background-color: var(--bg-page);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  overflow: hidden;
  will-change: transform, opacity;
  transition: background-color 160ms ease;
}

.chart-tile:nth-child(4n) {
  border-right: none;
}

.chart-tile:nth-last-child(-n+4) {
  border-bottom: none;
}

.chart-tile:hover {
  background-color: var(--bg-tile-hover);
}

.tile-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-shrink: 0;
}

.tile-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-transform: lowercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-type-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  white-space: nowrap;
}

.tile-canvas-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
}

.tile-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Dotted Legend Items inside each Tile (Shimmer on mouseover, click to edit) */
.tile-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex-shrink: 0;
  max-height: 44px;
  overflow: hidden;
}

.tile-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  border: 1px dotted var(--border-hairline);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 140ms ease;
}

.tile-legend-item:hover {
  border-style: solid;
  border-color: var(--ink);
}

.tile-legend-item::after {
  content: '';
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.75) 50%,
    transparent 100%
  );
  transform: skewX(-20deg);
  pointer-events: none;
}

.tile-legend-item:hover::after {
  animation: legendShimmer 600ms ease forwards;
}

@keyframes legendShimmer {
  0% { left: -120%; }
  100% { left: 160%; }
}

.legend-swatch {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-pct {
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

.legend-inline-input {
  width: 40px;
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--ink);
  color: var(--bg-page);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}
