/* ==========================================================================
   Mitcello Design Tools — splash / instrument catalog
   Tokens: tokens.css. Ambient field + tool previews: splash.js.
   ========================================================================== */

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

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  background:
    radial-gradient(ellipse 70% 45% at 50% -8%, color-mix(in srgb, var(--accent), transparent 94%), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

::selection {
  background: var(--accent-dim);
  color: var(--heading);
}

/* Ambient full-bleed dither: present but quiet */
.dither-field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  opacity: 0.34;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    oklch(0.08 0.01 145 / 0.14) 3px,
    oklch(0.08 0.01 145 / 0.14) 4px
  );
  opacity: 0.28;
  mix-blend-mode: multiply;
}

/* --------------------------------------------------------------------------
   Shell: single column idle → compact split on desktop when previewing
   -------------------------------------------------------------------------- */
.shell {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 48px) clamp(18px, 4vw, 28px) 28px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  align-items: start;
  transition: max-width .4s cubic-bezier(0.16, 1, 0.3, 1);
}

.shell.is-previewing {
  max-width: min(980px, calc(100% - 28px));
}

.panel-main {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(26px, 4vw, 40px);
  min-width: 0;
  padding: 4px 2px;
}

.panel-main::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -8px -10px;
  border-radius: 4px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg), transparent 6%) 0%,
    color-mix(in srgb, var(--bg), transparent 16%) 100%
  );
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--line), transparent 50%);
  pointer-events: none;
}

/* Stage: square plate matching catalog column, not full viewport height */
.panel-stage {
  display: none;
  min-width: 0;
  width: 100%;
}

.shell.is-previewing .panel-stage {
  display: block;
  animation: stageIn .4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes stageIn {
  from {
    opacity: 0;
    transform: translateX(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.stage-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--line), var(--accent) 14%);
  border-radius: 3px;
  background: #080808;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--copper), transparent 92%),
    0 12px 36px rgba(0, 0, 0, 0.45),
    0 0 28px color-mix(in srgb, var(--copper-glow), transparent 50%);
}

.dither-stage {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Desktop: catalog + square stage side by side, catalog height drives feel */
@media (min-width: 900px) {
  .shell.is-previewing {
    grid-template-columns: minmax(280px, 1fr) minmax(260px, 340px);
    gap: 24px;
    align-items: start;
  }

  .shell.is-previewing .panel-main {
    animation: catalogSlide .4s cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  @keyframes catalogSlide {
    from { transform: translateX(10px); }
    to { transform: translateX(0); }
  }

  .shell.is-previewing .panel-stage {
    width: 100%;
    max-width: 340px;
    justify-self: end;
    position: sticky;
    top: 28px;
  }
}

/* Mobile / tablet: compact square under catalog */
@media (max-width: 899px) {
  .shell.is-previewing {
    max-width: 720px;
    gap: 16px;
  }

  .shell.is-previewing .panel-stage {
    max-width: 320px;
    margin: 0 auto;
  }
}

/* --------------------------------------------------------------------------
   Masthead
   -------------------------------------------------------------------------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.site-title {
  font-family: var(--mono);
  font-size: clamp(26px, 5.5vw, 38px);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--heading);
  line-height: 1.08;
  margin-bottom: 12px;
}

.lede {
  max-width: 42ch;
  color: color-mix(in srgb, var(--text), var(--dim) 12%);
  font-size: 13.5px;
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
   Catalog
   -------------------------------------------------------------------------- */
.catalog-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

.catalog-head h2 {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
  position: relative;
}

.catalog-head h2::after {
  content: "";
  display: block;
  width: 28px;
  height: 1px;
  margin-top: 6px;
  background: var(--accent);
}

.catalog-count {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--copper);
}

.tool-list {
  list-style: none;
}

.tool-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px 14px;
  padding: 16px 12px;
  margin: 0 -12px;
  border: 1px solid transparent;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 30%);
  border-radius: 2px;
  text-decoration: none;
  color: inherit;
  transition:
    border-color .18s ease,
    background-color .18s ease,
    box-shadow .18s ease;
  min-height: 48px;
}

.tool-row:hover,
.tool-row:focus-visible,
.tool-row.is-active {
  border-color: color-mix(in srgb, var(--accent), transparent 60%);
  border-bottom-color: color-mix(in srgb, var(--accent), transparent 60%);
  background: color-mix(in srgb, var(--surface), transparent 8%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--copper), transparent 85%),
              0 0 24px var(--copper-glow);
  outline: none;
}

.tool-row:focus-visible {
  border-color: var(--accent);
}

.tool-row.is-launching {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent), transparent 92%);
  box-shadow: 0 0 32px var(--copper-glow), 0 0 10px var(--accent-dim);
}

.tool-index {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--dim);
  min-width: 1.6em;
  font-variant-numeric: tabular-nums;
}

.tool-row.is-active .tool-index,
.tool-row:hover .tool-index,
.tool-row:focus-visible .tool-index {
  color: var(--accent);
}

.tool-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.tool-name {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--heading);
}

.tool-name em {
  color: var(--accent);
  font-style: normal;
  margin: 0 1px;
}

.tool-desc {
  font-size: 12.5px;
  color: color-mix(in srgb, var(--dim), var(--text) 28%);
  line-height: 1.45;
  max-width: 40ch;
}

.tool-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.tool-status .led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-dim);
  animation: ledPulse 2.3s ease-in-out infinite;
}

@keyframes ledPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.tool-cue {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  opacity: 0;
  transition: opacity .15s ease, color .15s ease;
}

.tool-row.is-active .tool-cue,
.tool-row:hover .tool-cue,
.tool-row:focus-visible .tool-cue {
  opacity: 1;
  color: var(--copper);
}

.await {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--copper-track);
  display: flex;
  align-items: center;
  gap: 8px;
}

.await .cursor {
  color: var(--accent);
  animation: blink 0.95s steps(1) infinite;
}

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

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.foot {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 20px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--dim);
}

.foot a {
  color: var(--dim);
  text-decoration: none;
  transition: color .15s ease;
}

.foot a:hover,
.foot a:focus-visible {
  color: var(--accent);
  outline: none;
}

.foot a:focus-visible {
  box-shadow: 0 1px 0 var(--accent);
}

.foot-hint {
  color: var(--copper-track);
}

/* --------------------------------------------------------------------------
   Reduced motion / high contrast
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .tool-status .led,
  .await .cursor {
    animation: none;
  }
  .tool-row,
  .shell,
  .shell.is-previewing .panel-main,
  .shell.is-previewing .panel-stage {
    transition: none;
    animation: none;
  }
  .dither-field {
    opacity: 0.18;
  }
}

@media (prefers-contrast: more) {
  .dither-field,
  .scanlines {
    opacity: 0.1;
  }
  .panel-main::before {
    background: var(--bg);
    box-shadow: 0 0 0 1px var(--line);
  }
  .tool-desc {
    color: var(--text);
  }
  .tool-row:hover,
  .tool-row:focus-visible,
  .tool-row.is-active {
    border-color: var(--accent);
    background: var(--surface);
  }
}

@media (max-width: 540px) {
  .tool-row {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "idx name"
      "idx desc"
      "idx status";
    gap: 4px 12px;
    padding: 14px 8px;
  }
  .tool-index { grid-area: idx; align-self: start; padding-top: 3px; }
  .tool-body { grid-area: name; display: contents; }
  .tool-name { grid-area: name; }
  .tool-desc { grid-area: desc; }
  .tool-status { grid-area: status; margin-top: 4px; }
  .tool-cue { display: none; }
  .foot-hint { display: none; }
  .panel-main::before {
    inset: -4px 0;
    border-radius: 0;
  }
}
