/* ===========================================================
   style.css — retro CRT terminal portfolio

   Contents
     1. Fonts and design tokens
     2. Page base
     3. Monitor case and screen
     4. Screen layers (content, scanlines, vignette, HUD labels)
     5. Text effects
     6. Cover page        (index.html)
     7. Index page        (portfolio.html)
     8. Work pages        (works/*.html)
     9. Media player      (video / image frame drawn above the CRT layers)
    10. Channel bar
    11. Responsive rules

   Stacking order inside .screen-frame, bottom to top:
     .screen 0 · .crt-content 10 · .skip-hint 11 · .crt-canvas 25
     .curve-overlay 30 · .media-portal 32 · .now-viewing 40
   =========================================================== */


/* ===========================================================
   1. FONTS AND DESIGN TOKENS
   =========================================================== */
@import url('https://fonts.googleapis.com/css2?family=VT323&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* page and monitor case */
  --void: #0a0806;
  --case-lo: #241f1a;

  /* screen */
  --screen: #150d06;
  --phosphor: #ffb04a;
  --phosphor-hi: #ffd28c;
  --phosphor-dim: #8a5a24;
  --phosphor-glow: rgba(255, 160, 60, 0.55);
}


/* ===========================================================
   2. PAGE BASE
   =========================================================== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 2vh 2vw;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #1c1712 0%, var(--void) 70%);
  font-family: 'IBM Plex Mono', monospace;
}


/* ===========================================================
   3. MONITOR CASE AND SCREEN
   =========================================================== */
.monitor {
  position: relative;
  width: min(1300px, 95vw);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vw, 18px);
  padding: clamp(10px, 1.4vw, 16px);
  border-radius: clamp(18px, 2.2vw, 28px);
  background: linear-gradient(165deg, #55493e 0%, #3a322a 100%);
  box-shadow:
    0 50px 100px rgba(0, 0, 0, 0.65),
    0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.screen-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: clamp(10px, 1.6vw, 18px);
  overflow: hidden;
  cursor: pointer;
  background: #000;
  animation: flicker 6.5s infinite;
}

/* one-time power-on flourish (class added by js/crt.js) */
.screen-frame.power-on {
  animation: powerOn 750ms ease-out;
}

.screen {
  position: absolute;
  inset: 0;
  background: var(--screen);
}

@keyframes flicker {
  0%, 96%, 100% { filter: brightness(1); }
  97%           { filter: brightness(1.04); }
  98%           { filter: brightness(0.97); }
}

@keyframes powerOn {
  0%   { opacity: 0; filter: brightness(2.4); }
  10%  { opacity: 1; filter: brightness(2.4); }
  22%  { filter: brightness(0.55); }
  38%  { filter: brightness(1.35); }
  60%  { filter: brightness(0.88); }
  100% { opacity: 1; filter: brightness(1); }
}


/* ===========================================================
   4. SCREEN LAYERS
   =========================================================== */

/* the text layer: every page's stage lives in here */
.crt-content {
  position: absolute;
  inset: 0;
  z-index: 10;
  padding: clamp(20px, 3.2vw, 52px) clamp(24px, 3.6vw, 64px);
  overflow-y: auto;
  color: var(--phosphor);
  font-family: 'IBM Plex Mono', monospace;
}

.crt-content::-webkit-scrollbar {
  width: 0;
}

/* scanlines + slow sweep, drawn by js/crt.js */
.crt-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 25;
  pointer-events: none;
}

/* darkened corners, like a curved glass tube */
.curve-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background: radial-gradient(
    ellipse 145% 145% at 50% 50%,
    transparent 38%,
    rgba(0, 0, 0, 0.55) 78%,
    rgba(0, 0, 0, 0.92) 100%
  );
}

/* small status labels on the glass */
.now-viewing {
  position: absolute;
  top: 10px;
  left: 16px;
  z-index: 40;
  opacity: 0.8;
  pointer-events: none;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--phosphor-dim);
}

.skip-hint {
  position: absolute;
  right: 16px;
  bottom: 10px;
  z-index: 11;
  opacity: 0.6;
  font-size: 10px;
  color: var(--phosphor-dim);
}


/* ===========================================================
   5. TEXT EFFECTS
   =========================================================== */
.glow {
  text-shadow:
    0 0 4px var(--phosphor-glow),
    0 0 14px var(--phosphor-glow),
    0 0 1px rgba(255, 255, 255, 0.5);
}

.glow-strong {
  text-shadow:
    -1px 0 rgba(255, 70, 70, 0.35),
    1px 0 rgba(70, 210, 255, 0.3),
    0 0 6px var(--phosphor-hi),
    0 0 22px var(--phosphor-glow),
    0 0 48px var(--phosphor-glow);
  transition: text-shadow 0.35s ease;
}

.dim {
  color: var(--phosphor-dim);
}

.cursor-block {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--phosphor-hi);
  box-shadow: 0 0 8px var(--phosphor-glow);
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}


/* ===========================================================
   STAGES — each page has exactly one stage. The page's HTML
   marks it .is-active; the others do not exist on that page.
   =========================================================== */
#stage-intro,
#stage-menu,
#stage-item {
  display: none;
  height: 100%;
  flex-direction: column;
}

#stage-intro.is-active,
#stage-menu.is-active,
#stage-item.is-active {
  display: flex;
}


/* ===========================================================
   6. COVER PAGE
   =========================================================== */
#stage-boot {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(12px, 1.3vw, 15px);
  line-height: 1.7;
}

#stage-boot .line {
  opacity: 0;   /* faded in one by one by js/main.js */
}

#stage-intro {
  align-items: flex-start;
  justify-content: center;
}

#stage-intro .title {
  margin: 0 0 6px 0;
  font-family: 'VT323', monospace;
  font-size: clamp(46px, 7vw, 96px);
  line-height: 0.95;
  letter-spacing: 0.02em;
}

#stage-intro .subtitle {
  margin-bottom: clamp(24px, 4vh, 48px);
  font-family: 'VT323', monospace;
  font-size: clamp(20px, 2.4vw, 32px);
  color: var(--phosphor-dim);
}

#stage-intro .meta-line {
  margin: 2px 0;
  font-size: clamp(13px, 1.4vw, 16px);
}

#stage-intro .meta-label {
  color: var(--phosphor-dim);
}

#stage-intro .prompt-line {
  margin-top: clamp(30px, 5vh, 56px);
  font-size: clamp(14px, 1.6vw, 18px);
}


/* ===========================================================
   7. INDEX PAGE
   =========================================================== */
.menu-head {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--phosphor-dim);
  font-family: 'VT323', monospace;
  font-size: clamp(22px, 2.6vw, 30px);
}

.menu-list {
  flex: 1;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  gap: 18px;
  padding: 9px 10px;
  overflow: hidden;
  border-left: 3px solid transparent;
  font-size: clamp(13px, 1.5vw, 16px);
  white-space: nowrap;
  text-overflow: ellipsis;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.menu-item .idx {
  flex-shrink: 0;
  width: 2.4em;
  color: var(--phosphor-dim);
}

.menu-item .fname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-item.active {
  border-left-color: var(--phosphor-hi);
  background: rgba(255, 170, 80, 0.08);
  color: var(--phosphor-hi);
  text-shadow: 0 0 6px var(--phosphor-glow);
}

.menu-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--phosphor-dim);
  font-size: clamp(11px, 1.2vw, 13px);
  color: var(--phosphor-dim);
}


/* ===========================================================
   8. WORK PAGES
   =========================================================== */
.item-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--phosphor-dim);
}

.item-title {
  font-family: 'VT323', monospace;
  font-size: clamp(26px, 3.2vw, 38px);
}

.item-tags {
  font-size: clamp(11px, 1.2vw, 13px);
  color: var(--phosphor-dim);
}

.item-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 clamp(18px, 3.6vw, 56px);
}

.field-label {
  margin: 18px 0 6px 0;
  font-family: 'VT323', monospace;
  font-size: clamp(15px, 1.7vw, 19px);
  letter-spacing: 0.05em;
  color: var(--phosphor-hi);
}

.field-label:first-child,
.media-box.float-left + .field-label {
  margin-top: 0;
}

.field-text {
  max-width: 100%;
  font-size: clamp(13px, 1.4vw, 15px);
  line-height: 1.65;
  white-space: pre-wrap;
  text-shadow: 0 0 3px var(--phosphor-glow);
}

.item-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--phosphor-dim);
  font-size: clamp(11px, 1.2vw, 13px);
  color: var(--phosphor-dim);
}

.item-foot a {
  color: inherit;
  text-decoration: none;
}

.item-foot a:hover {
  color: var(--phosphor-hi);
}

/* The frame that reserves space for a work's media. The real video/image
   is drawn on top of it by the media player (section 9). */
.media-box {
  position: relative;
  min-height: 260px;
  margin: 14px 0;
  border: 1px solid var(--phosphor-dim);
}

/* wide screens: media sits left of the text */
.media-box.float-left {
  float: left;
  width: min(46%, 480px);
  min-height: 0;
  aspect-ratio: 16 / 9;
  margin: 0 22px 12px 0;
}

.media-box.float-left.portrait {
  width: min(26%, 240px);
  aspect-ratio: 9 / 16;
}

/* link box shown instead of media (UniReviews → GitHub) */
.repo-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 14px 0;
  padding: 28px 20px;
  border: 1px solid var(--phosphor-dim);
  background: rgba(255, 170, 80, 0.04);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-align: center;
  text-decoration: none;
  color: var(--phosphor);
}

.repo-link:hover {
  border-color: var(--phosphor-hi);
  color: var(--phosphor-hi);
  text-shadow: 0 0 6px var(--phosphor-glow);
}

.repo-link .rl-line {
  font-size: 11px;
  color: var(--phosphor-dim);
}

.repo-link .rl-cta {
  font-size: 14px;
  font-weight: 600;
}


/* ===========================================================
   9. MEDIA PLAYER
   The actual image/video lives in .media-portal, above the scanline
   and vignette layers, so the piece itself is never dimmed or tinted.
   js/player.js moves it to sit exactly over the page's .media-box.
   =========================================================== */
.media-portal {
  position: absolute;
  z-index: 32;
  display: none;
  overflow: hidden;
  pointer-events: none;
}

.media-portal.active {
  display: block;
  pointer-events: auto;
}

.player {
  position: absolute;
  background: #000;
  container-type: inline-size;   /* lets the controls adapt to the player's width (see below) */
}

.player video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: pointer;
}

.player img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player img:fullscreen,
.player img:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  background: #000;
}

/* buttons shared by the video controls, image controls and slide arrows */
.pc-btn,
.cn-btn {
  border: 1px solid var(--phosphor-dim);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  font-family: inherit;
  line-height: 1;
  color: var(--phosphor);
  cursor: pointer;
}

.pc-btn:hover,
.cn-btn:hover {
  border-color: var(--phosphor-hi);
  color: var(--phosphor-hi);
  text-shadow: 0 0 6px var(--phosphor-glow);
}

/* --- video controls (bottom bar) --- */
.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.6) 65%, rgba(0, 0, 0, 0) 100%);
  font-family: 'IBM Plex Mono', monospace;
}

.pc-btn {
  flex-shrink: 0;
  padding: 4px 7px;
  font-size: 11px;
}

.pc-play {
  min-width: 1.8em;
  text-align: center;
}

.pc-time {
  flex-shrink: 0;
  font-size: 11px;
  white-space: nowrap;
  color: var(--phosphor-dim);
}

/* seek bar */
.pc-scrub {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 14px;
  cursor: pointer;
  touch-action: none;
}

.pc-scrub-track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
}

.pc-scrub-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 3px;
  background: var(--phosphor);
  box-shadow: 0 0 6px var(--phosphor-glow);
}

.pc-scrub-fill::after {   /* the draggable knob */
  content: '';
  position: absolute;
  right: -4px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--phosphor-hi);
  box-shadow: 0 0 6px var(--phosphor-glow);
  transform: translateY(-50%);
}

/* Narrow players (portrait videos on a phone): drop the time read-out and
   tighten the buttons so play / seek / sound / fullscreen all fit. */
@container (max-width: 300px) {
  .player-controls {
    gap: 6px;
    padding: 6px 7px;
  }

  .pc-time {
    display: none;
  }

  .pc-btn {
    padding: 4px 5px;
  }
}

/* --- image controls (fullscreen button) --- */
.img-controls {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 2;
}

/* --- slide arrows when a work has several clips or images --- */
.carousel-nav {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 9px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.55) 65%, rgba(0, 0, 0, 0) 100%);
  font-family: 'IBM Plex Mono', monospace;
}

.cn-btn {
  padding: 2px 9px;
  font-size: 13px;
}

.cn-count {
  font-size: 11px;
  white-space: nowrap;
  color: var(--phosphor-dim);
}


/* ===========================================================
   10. CHANNEL BAR (bottom of the monitor case)
   =========================================================== */
.channel-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--case-lo), #34291f);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.5),
    inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}

.channel-bar .ch-label {
  margin-right: 4px;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #8a7f72;
}

.channel-divider {
  width: 1px;
  height: 16px;
  margin: 0 4px;
  background: #5a5044;
}

.channel-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 30px;
  padding: 3px 6px 0;
  border: 1px solid #241d16;
  border-radius: 5px;
  background: linear-gradient(180deg, #5a5044, #332c25);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 2px 3px rgba(0, 0, 0, 0.5);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  line-height: 1;
  text-decoration: none;
  color: #c9b9a0;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}

.channel-btn:hover {
  background: linear-gradient(180deg, #6a5f50, #3d352c);
}

.channel-btn .ch-num {
  font-size: 11px;
}

/* the "R" button that returns to the cover */
.channel-btn.cover {
  margin-right: 8px;
  font-weight: 600;
}

/* the channel of the page you are on */
.channel-btn.active {
  border-color: #c96e12;
  background: linear-gradient(180deg, #ff9d2e, #c96e12);
  box-shadow:
    0 0 8px var(--phosphor-glow),
    0 1px 0 rgba(255, 255, 255, 0.3) inset;
  color: #1a0f06;
}

/* channels already opened this session get a small dot */
.channel-btn.visited:not(.active) .ch-num {
  color: var(--phosphor-hi);
}

.channel-btn.visited:not(.active)::after {
  content: '';
  width: 3px;
  height: 3px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--phosphor-dim);
}


/* ===========================================================
   11. RESPONSIVE
   =========================================================== */

/* Below this width the text column next to a floated media box gets too
   narrow to read, so the media stacks above the text instead. */
@media (max-width: 900px) {
  .media-box.float-left {
    float: none;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 14px 0;
  }

  .media-box.float-left.portrait {
    width: min(60%, 320px);
    aspect-ratio: 9 / 16;
    margin: 14px auto;
  }
}

/* phones: the screen fills the width instead of keeping 16:10 */
@media (max-width: 700px) {
  body {
    padding: 1vh 2vw;
  }

  .screen-frame {
    aspect-ratio: auto;
    width: 100%;
    height: 78vh;
    border-radius: 14px;
  }

  .crt-content {
    padding: 16px 18px;
  }
}
