/* Tyler Faux
   1-bit Macintosh aesthetic: warm paper, ink, pixel display type, subtle CRT veil. */

:root {
  --paper: #f4f1ea;
  --paper-dim: #e9e4d8;
  --ink: #1a1714;
  --ink-soft: #4a4640;
  --line: #cfc8b8;
  --accent: #e8703a;

  --display: 'Silkscreen', 'Courier New', monospace;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---- frame / layout ------------------------------------------------------ */
.frame {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: clamp(0.5rem, 2vh, 1.4rem);
  padding: clamp(1rem, 3.2vh, 2.2rem) clamp(1rem, 4vw, 3rem);
  max-width: 1180px;
  margin: 0 auto;
}

/* ---- masthead ------------------------------------------------------------ */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1.5px solid var(--ink);
  padding-bottom: 0.6rem;
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1rem, 2.6vw, 1.5rem);
  letter-spacing: 0.02em;
  margin: 0;
}

.subtitle {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---- stage --------------------------------------------------------------- */
.stage-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(1rem, 4vw, 3rem);
  min-height: 0;
}

.screen {
  position: relative;
  height: 100%;
  min-height: 0;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
  box-shadow:
    inset 0 0 0 1px var(--paper),
    inset 0 0 22px rgba(26, 23, 20, 0.06),
    3px 4px 0 0 rgba(26, 23, 20, 0.14);
  overflow: hidden;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 0.6rem;
  left: 0.7rem;
  font-family: var(--display);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  display: flex;
  gap: 0.32rem;
  align-items: center;
  user-select: none;
  pointer-events: none;
  opacity: 0.72;
}
.hud-label {
  opacity: 0.6;
}
.hud-sep {
  opacity: 0.4;
}

/* play button only shows in reduced-motion mode */
.play {
  position: absolute;
  inset: auto 0 0 0;
  margin: auto;
  bottom: 1.2rem;
  width: max-content;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-size: 0.72rem;
  padding: 0.5rem 0.9rem;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: none;
}
body.reduced .play {
  display: block;
}

.paused-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  font-family: var(--display);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.2s;
}
body.paused .paused-badge {
  opacity: 1;
}

/* ---- caption ------------------------------------------------------------- */
.caption {
  margin: 0;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.caption.show {
  opacity: 1;
  transform: none;
}

.cap-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.3rem, 3.4vw, 2.1rem);
  line-height: 1.1;
  margin: 0 0 0.7rem;
  display: flex;
  align-items: center;
}

.caret {
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 0.18em;
  background: var(--accent);
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

.cap-meta {
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.9rem;
}
.cap-role {
  color: var(--ink);
}
.cap-dot {
  margin: 0 0.45rem;
  opacity: 0.5;
}

.cap-blurb {
  font-size: clamp(0.82rem, 1.05vw, 0.95rem);
  line-height: 1.62;
  max-width: 38ch;
  margin: 0;
  color: var(--ink-soft);
}

/* ---- tray ---------------------------------------------------------------- */
.tray {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(0.5rem, 1.6vw, 1.1rem);
  flex-wrap: wrap;
  border-top: 1.5px solid var(--ink);
  padding-top: clamp(0.6rem, 1.6vh, 1.1rem);
}

.tray-item {
  position: relative;
  width: clamp(38px, 6vw, 54px);
  height: clamp(38px, 6vw, 54px);
  padding: 6px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.16s ease, border-color 0.16s ease, filter 0.25s ease;
  filter: grayscale(0.85) contrast(0.95) opacity(0.55);
}
.tray-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
}
.tray-item:hover {
  filter: grayscale(0) opacity(1);
  transform: translateY(-3px);
  border-color: var(--ink);
}
.tray-item.active {
  filter: grayscale(0) opacity(1);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent) inset, 2px 3px 0 0 rgba(26, 23, 20, 0.16);
}

.tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  font-family: var(--display);
  font-size: 0.56rem;
  white-space: nowrap;
  background: var(--ink);
  color: var(--paper);
  padding: 0.28rem 0.45rem;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.tray-item:hover .tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- colophon ------------------------------------------------------------ */
.colophon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  flex-wrap: wrap;
}
.colophon a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.colophon a:hover {
  border-bottom-color: var(--accent);
}
.colophon .links {
  display: flex;
  gap: 0.9rem;
}
.colophon .links a[aria-disabled='true'] {
  color: var(--ink-soft);
  opacity: 0.55;
  pointer-events: none;
}
.hint {
  font-family: var(--display);
  font-size: 0.54rem;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

/* ---- CRT veil ------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  /* scanlines */
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(26, 23, 20, 0.035) 0px,
    rgba(26, 23, 20, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  /* vignette */
  box-shadow: inset 0 0 180px rgba(26, 23, 20, 0.16);
  mix-blend-mode: multiply;
}

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 720px) {
  body {
    overflow: auto;
  }
  .frame {
    height: auto;
    min-height: 100dvh;
  }
  .stage-wrap {
    grid-template-columns: 1fr;
  }
  .screen {
    aspect-ratio: 4 / 3;
    height: auto;
  }
  .cap-blurb {
    max-width: none;
  }
  .masthead {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }
  .hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .caret {
    animation: none;
  }
}
