/* Main page refactor layer
   Consolidates the former stacked inline hero/goofs/profile/debugger patches into one cascade.
   Safe scope: main portfolio shell only. Does not change Signal Run mechanics, Firebase, highscores,
   question bank, portal code, or audio/video asset paths. */

:root {
  --site-shell-width: 1060px;
  --hero-copy-width: 780px;
  --hero-copy-x: -28px;
  --hero-copy-y: -3px;
  --hero-copy-font-size: 14px;
  --hero-copy-line-height: 1.18;
  --hero-demo-width: 390px;
  --goof-tape-desktop-width: 514px;
  --goof-tape-mobile-width: 685px;
}


/* Readability patch: larger hero intro and demo controls for easier scanning. */
#home .tagline.terminal-typewriter {
  text-shadow: 0 0 6px rgba(125, 249, 255, 0.22);
}

#home .copy-module .terran-demo-label {
  font-size: 13px !important;
  line-height: 1.15 !important;
}

#home .copy-module .terran-demo-subline,
#home .copy-module .terran-demo-time,
#home .copy-module .terran-mini-control {
  font-size: 10px !important;
  line-height: 1.15 !important;
}

/* ---------- Hero / top viewport ---------- */
.hero-right-rail:empty {
  display: none !important;
}

#home {
  position: relative;
  min-height: 0 !important;
}

#home .hero-command-row {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
}

#home .copy-module {
  position: relative;
  z-index: 5;
  display: grid !important;
  gap: 0 !important;
}

#home .tagline.terminal-typewriter {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}

#home .terminal-typewriter .terminal-typed-line {
  display: block !important;
  width: 100% !important;
}

#home .terminal-typewriter .terminal-typed-line[data-type-line=""] {
  display: block !important;
  min-height: 0 !important;
}

#home .copy-module .demo-under-welcome {
  justify-self: start !important;
  max-width: 100% !important;
}

#home .copy-module .demo-under-welcome.terran-demo-console {
  padding: 5px !important;
}

#home .copy-module .demo-under-welcome .terran-demo-main {
  min-height: 31px !important;
  padding: 4px 6px !important;
}

#home .copy-module .demo-under-welcome .terran-demo-status-row,
#home .copy-module .demo-under-welcome .terran-demo-progress {
  margin-top: 4px !important;
}

#home .copy-module .demo-under-welcome .terran-mini-control {
  min-height: 26px !important;
  padding: 5px 8px !important;
  font-size: 10px !important;
}

#home .copy-module .demo-under-welcome .terran-demo-main,
#home .copy-module .demo-under-welcome .terran-demo-status-row,
#home .copy-module .demo-under-welcome .terran-demo-progress {
  max-width: 100% !important;
}

nav[aria-label="Main navigation"] {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 0 !important;
  margin-top: 0 !important;
}

/* ---------- Profile CD launcher ---------- */
.profile-photo-wrap {
  position: relative !important;
}

#signal-run-launch.profile-cd-launch,
.profile-cd-launch {
  position: absolute !important;
  top: -10px !important;
  left: -10px !important;
  right: auto !important;
  z-index: 6 !important;
  display: grid !important;
  place-items: center !important;
  width: clamp(56px, 7vw, 82px) !important;
  min-height: clamp(56px, 7vw, 82px) !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
  transform: none !important;
  pointer-events: auto !important;
}

#signal-run-launch.profile-cd-launch .hero-game-disc {
  width: clamp(52px, 6.5vw, 76px) !important;
  height: clamp(52px, 6.5vw, 76px) !important;
  margin: 0 !important;
  pointer-events: none !important;
}

#signal-run-launch.profile-cd-launch:hover .hero-game-disc,
#signal-run-launch.profile-cd-launch:focus-visible .hero-game-disc {
  transform: scale(1.04) rotate(8deg) !important;
}

#signal-run-launch.profile-cd-launch .hero-game-launch-label {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  max-width: 1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

#signal-run-launch.profile-cd-launch .hero-game-launch-label::before,
#signal-run-launch.profile-cd-launch .hero-game-launch-label::after {
  content: none !important;
}

/* ---------- Goofs tape recorder canvas widget ---------- */
.goof-standalone-zone {
  position: relative;
  margin: clamp(16px, 2.2vw, 26px) clamp(10px, 2vw, 22px) 0;
  padding: clamp(12px, 1.6vw, 18px) clamp(12px, 2.3vw, 28px) clamp(26px, 4vw, 48px);
  border-top: 1px dashed rgba(57, 255, 136, 0.38);
  border-bottom: 1px solid rgba(100, 210, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(3, 14, 18, 0.38), rgba(0, 0, 0, 0.06) 58%, rgba(3, 14, 18, 0.18));
  min-height: 0;
}

.goof-standalone-header {
  max-width: 100%;
  margin: 0;
}

.goof-standalone-header h2 {
  margin: 0 0 10px;
  color: #ffd86d;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: clamp(8px, 0.9vw, 11px);
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.goof-standalone-header p {
  margin: 0;
  color: #57ff9a;
  font-family: "Share Tech Mono", "Courier New", monospace;
  font-size: clamp(12px, 1.35vw, 17px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

#goofs .goof-tape-widget {
  position: relative;
  width: min(96%, 514px) !important;
  margin: clamp(12px, 1.7vw, 20px) auto 0;
  line-height: 0;
}

#goofs .goof-tape-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.34));
  user-select: none;
  -webkit-user-drag: none;
}

#goofs .goof-tape-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: pointer;
  touch-action: manipulation;
}

#goofs .goof-tape-canvas:focus-visible {
  outline: 2px solid rgba(255, 216, 109, 0.95);
  outline-offset: 4px;
}

.goof-standalone-return {
  margin-top: 0;
}

/* ---------- Desktop final layout ---------- */
@media (min-width: 781px) {
  .terminal {
    width: min(var(--site-shell-width), calc(100% - 24px)) !important;
    max-width: var(--site-shell-width) !important;
    opacity: 1 !important;
    transform: translate(0px, -13px) !important;
  }

  .topbar {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    font-size: 13px !important;
    transform: translate(0px, 0px) !important;
  }

  #home {
    padding: 12px 174px 13px 38px !important;
    background-color: rgba(0, 0, 0, 0) !important;
  }

  #home .kicker {
    margin: 0 0 5px !important;
    max-width: min(560px, 100%) !important;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    letter-spacing: 0.12em !important;
    transform: translate(0px, 0px) !important;
  }

  #home .glitch-title {
    margin: 0 !important;
    font-family: "VT323", "Courier New", monospace !important;
    font-size: 98px !important;
    line-height: 0.7 !important;
    letter-spacing: 0.105em !important;
    transform: translate(1px, 0px) !important;
    text-shadow: 0 0 7px rgba(57, 255, 136, 0.42), 0 0 13px rgba(125, 249, 255, 0.24) !important;
  }

  #home .copy-module {
    width: min(var(--hero-copy-width), calc(100vw - 90px)) !important;
    max-width: min(var(--hero-copy-width), calc(100vw - 90px)) !important;
    margin-top: -8px !important;
    transform: translate(var(--hero-copy-x), var(--hero-copy-y)) !important;
    font-family: "Share Tech Mono", "Courier New", monospace !important;
  }

  #home .tagline.terminal-typewriter,
  #home .terminal-typewriter .terminal-typed-line {
    font-size: var(--hero-copy-font-size) !important;
    line-height: var(--hero-copy-line-height) !important;
    white-space: normal !important;
    overflow: visible !important;
    border-right: 0 !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }

  #home .terminal-typewriter .terminal-typed-line[data-type-line=""] {
    height: 0.28em !important;
  }

  #home .terminal-typewriter .terminal-typing-caret {
    display: none !important;
  }

  #home .copy-module .demo-under-welcome {
    width: min(var(--hero-demo-width), 100%) !important;
    margin-top: 10px !important;
    transform: translate(0px, 0px) scale(1) !important;
    transform-origin: center center !important;
  }

  nav[aria-label="Main navigation"] {
    font-size: 11px !important;
    transform: translate(0px, 0px) !important;
  }

  .profile-card {
    padding: 16px !important;
    max-width: 980px !important;
    gap: 18px !important;
  }

  .profile-photo-wrap {
    width: 175px !important;
    max-width: 175px !important;
    transform: translate(-9px, 1px) scale(1.1) !important;
    transform-origin: center center !important;
  }

  #contact {
    padding: 0 !important;
    margin-top: 0 !important;
    max-width: 980px !important;
    font-size: 16px !important;
  }

  #goofs {
    padding: 0 !important;
    margin-top: 10px !important;
    max-width: 1200px !important;
  }

  #goofs .goof-tape-widget {
    margin-top: -80px !important;
    transform: translate(-2px, 32px) scale(1) !important;
    transform-origin: center center !important;
  }

  [data-drawer-open="audio"] {
    bottom: 116px !important;
    left: 14px !important;
    transform: translate(0px, 0px) !important;
  }

  [data-drawer-open="video"] {
    bottom: 116px !important;
    right: 14px !important;
    transform: translate(0px, 0px) !important;
  }

  [data-drawer-open="social"] {
    bottom: 54px !important;
    right: 14px !important;
    transform: translate(0px, 0px) !important;
  }

  footer {
    padding-top: 18px !important;
    padding-bottom: 18px !important;
    font-size: 12px !important;
    transform: translate(0px, 0px) !important;
  }
}

/* ---------- Mobile layout ---------- */
@media (max-width: 780px) {
  #home {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "kicker"
      "title"
      "copy" !important;
    justify-items: stretch !important;
    gap: 12px !important;
    min-height: 0 !important;
    padding: 22px 16px 18px !important;
  }

  #home .kicker {
    grid-area: kicker !important;
    width: 100% !important;
    max-width: none !important;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    line-height: 1.45 !important;
  }

  #home .hero-command-row {
    display: contents !important;
  }

  #home .glitch-title {
    grid-area: title !important;
    width: 100% !important;
    max-width: 100% !important;
    font-size: clamp(1.65rem, 7vw, 2.45rem) !important;
    line-height: 0.95 !important;
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }

  #home .copy-module {
    grid-area: copy !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    transform: none !important;
  }

  #home .tagline.terminal-typewriter,
  #home .terminal-typewriter .terminal-typed-line {
    max-width: 100% !important;
    font-size: 16px !important;
    line-height: 1.25 !important;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }

  #home .hero-right-rail,
  #signal-run-launch.profile-cd-launch {
    display: none !important;
  }

  nav[aria-label="Main navigation"] {
    grid-template-columns: 1fr !important;
    gap: clamp(7px, 1vw, 12px) !important;
  }

  .goof-standalone-zone {
    margin-inline: 0;
    padding-inline: 14px;
  }

  #goofs .goof-tape-widget {
    width: min(96%, 685px) !important;
    margin-top: 18px !important;
    transform: none !important;
  }
}
