/* css variables for sizing and colors */
:root {
  --page-fade-duration: 700ms;
  --pvm-graphic-width: 400px;
  --color-text-dark: #000;
  --color-text-light: #fff;
  --color-text-muted: rgb(102, 102, 102);
}

/* SonyCam OSD font */
@font-face {
  font-family: 'SonyCam';
  src: url('/assets/fonts/sonycam.otf') format('opentype');
  font-display: swap;
}

/* base styles */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  text-align: center;
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  transition: opacity var(--page-fade-duration) ease, background-color 0.3s, color 0.3s;
  opacity: 1;
}


html.page-loading body,
body.loading {
  opacity: 0;
}

/* layout */
.layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: opacity 0.25s, background-color 0.3s, color 0.3s;
}

html.home-return-transition .layout {
  transition-duration: var(--page-fade-duration), 0.3s, 0.3s;
}

html.home-intro.home-returning .layout {
  opacity: 0;
}

html.home-exiting .layout {
  opacity: 0;
  transition-duration: 180ms;
}

.intro {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  transition: background-color 0.3s, color 0.3s;
}

h1 {
  font-family: "BIZ UDPMincho", serif;
  font-weight: normal;
  margin: 0.5em 0;
  letter-spacing: -2px;
}

.home-title {
  font-size: 3rem;
  position: relative;
  transition: filter 30s ease, opacity var(--page-fade-duration) ease;
  will-change: filter;
  cursor: default;
}

@keyframes home-title-intro {
  from { opacity: 0; }
  to { opacity: 1; }
}

html.home-intro .home-title {
  animation: home-title-intro var(--page-fade-duration) ease 100ms forwards;
}

html.home-intro.home-returning .home-title {
  animation: none;
  opacity: 1;
}

html.home-intro .pvm-container,
html.home-intro .message,
html.home-intro .site-footer {
  opacity: 0;
}

html.home-intro .message,
html.home-intro .site-footer {
  will-change: opacity, transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

html.home-intro.home-pvm-ready .pvm-container,
html.home-intro .message.intro-visible,
html.home-intro .site-footer.intro-visible {
  opacity: 1;
}

html.home-intro .message.intro-prepared:not(.intro-visible),
html.home-intro .site-footer.intro-prepared:not(.intro-visible) {
  opacity: 0.001;
}

.home-title:hover {
  filter: blur(0.15em) contrast(25) brightness(1.2);
}


p {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 2em 0;
}

/* link styles */
a {
  text-decoration: none;
  cursor: pointer;
  color: inherit;
}
a:visited { color: inherit; }
a:hover, a:focus, a:active { color: inherit; }

/* make homepage "gallery" link hover match footer icon hover */
.message a {
  display: inline-block;
  border-radius: 6px;
  padding: 0.25em 0.5em;
  transition: color 0.2s, background 0.2s, opacity 0.2s;
}
.message a:hover, .message a:focus {
  color: var(--color-text-muted);
}

/* When hovering the "gallery" text, hide the TV glow and reflection */
.message a:hover ~ .pvm-container .pvm-glow-reflection,
.message a:focus ~ .pvm-container .pvm-glow-reflection,
.message a:hover ~ .pvm-container .media-glow-canvas,
.message a:focus ~ .pvm-container .media-glow-canvas {
  display: none !important;
}

/* maintenance state dims the link further; JS toggles text and href only */
.maintenance-on .message a {
  opacity: 0.5;
}

/* under construction tape */
.caution-tape {
  width: 100vw;
  height: 20px;
  background: repeating-linear-gradient(-45deg, rgb(255, 215, 0) 0px, rgb(255, 215, 0) 20px, rgb(0, 0, 0) 20px, rgb(0, 0, 0) 40px);
  transform: rotate(-2deg);
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.2);
  margin: 1rem 0;
  visibility: hidden;
}

.caution-tape.active {
  visibility: visible;
}

/* pvm container and screen */
.pvm-container {
  position: relative;
  display: inline-block;
  margin: 30px auto;
  overflow: visible;
  pointer-events: auto;
  transform: translateZ(0);
  /* Ensure blend modes (phosphor, scanlines) blend within this box only */
  isolation: isolate;
  transition: opacity var(--page-fade-duration) ease;
}

/* Subline styling for effect status messages (subtitle under main line) */
#effect-status-message .effect-sub {
  display: block;
  margin-top: 4px;
  font-size: 0.85em;
  color: #888;
  letter-spacing: 0.4px;
}

.pvm {
  width: var(--pvm-graphic-width);
  height: auto;
  aspect-ratio: 1606 / 1593;
  position: relative;
  z-index: 4;
  pointer-events: auto;
  transition: filter 0.3s, opacity 0.3s, background-color 0.3s, color 0.3s;
}

.pvm-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.pvm-placeholder img {
  display: block;
  width: 100%;
  height: auto;
}

.pvm svg {
  width: 100%;
  height: 100%;
  display: block;
  transition: filter 0.3s, opacity 0.3s, background-color 0.3s, color 0.3s;
}

/* text glow reflection */
.pvm-glow-reflection {
  position: absolute;
  top: 2%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 300px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0) 100%);
  z-index: 11;
  opacity: 1;
  filter: blur(4px);
  transition: all 0.3s ease, width 0.3s cubic-bezier(.4,0,.2,1);
  mix-blend-mode: screen;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  text-shadow:
    0 0 8px rgba(255,255,255,0.8),
    0 0 16px rgba(255,255,255,0.6),
    0 0 32px rgba(255,255,255,0.4);
  white-space: pre-line;
  font: inherit;
  text-align: center;
  background: none;
  display: block;
  margin: 0 auto 1em auto;
  will-change: opacity, transform, filter;
  animation-delay: 0.2s;
}

/* scanlines */
.scanlines {
  background: repeating-linear-gradient(to bottom,
    transparent 0px,
    transparent 0.5px,
    rgba(0, 0, 0, 0.25) 0.5px,
    rgba(0, 0, 0, 0.25) 1px);
  mix-blend-mode: normal;
  opacity: 1;
  border-radius: 0;
  overflow: hidden;
  position: absolute;
  pointer-events: none;
  z-index: 5; /* above video (1), phosphor (2) and ct overlay (3), below bezel */
  transition: opacity 0.3s ease;
}

.phosphor {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  opacity: 0.2;
  /* Blend phosphor pattern with underlying image luminance for a more "made of phosphors" feel */
  mix-blend-mode: soft-light;
  image-rendering: pixelated;
  transition: opacity 0.3s ease;
}

/* hide phosphor when tv is off */
body.power-off .phosphor {
  opacity: 0 !important;
}

/* hide phosphor when toggled off */
.phosphor-disabled .phosphor {
  opacity: 0 !important;
}

/* vignette effect for pixi canvas */
.pvm-pixi-canvas::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center,
      transparent 60%,
      rgba(0, 0, 0, 0.1) 80%,
      rgba(0, 0, 0, 0.3) 90%,
      rgba(0, 0, 0, 0.5) 100%);
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.pvm-pixi-canvas.vignette-fade::after {
  opacity: 1;
}

/* message animation */
.message span {
  display: inline-block;
  font-weight: italic;
  font-size: 1rem;
  animation: wave 15s ease-in-out infinite;
  text-shadow: none;
}

.message,
.site-footer {
  transition: opacity var(--page-fade-duration) ease;
}

/* footer styles */
.site-footer {
  text-align: center;
  padding: 1rem;
  background: none;
  color: inherit;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.footer-links a {
  color: var(--color-text-dark);
  text-decoration: none;
  transition: color 0.2s, background 0.2s, opacity 0.2s;
  border-radius: 6px;
  padding: 0.25em 0.5em;
}

.footer-links a:hover, .footer-links a:focus {
  color: var(--color-text-muted);
}

/* animations */
@keyframes floatUpDown {
  0% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
  100% { transform: translateY(0); }
}

@keyframes wave {
  0% { transform: translateY(0); }
  25% { transform: translateY(-10px); }
  50% { transform: translateY(10px); }
  75% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}

@keyframes glimmer {
  0% { text-shadow: none; }
  10% {
    text-shadow:
      0 0 5px rgb(255, 255, 255),
      0 0 10px rgb(255, 255, 255),
      0 0 15px rgb(255, 255, 255),
      0 0 20px rgb(255, 255, 255);
  }
  50% {
    text-shadow:
      0 0 8px rgb(255, 255, 255),
      0 0 15px rgb(255, 255, 255),
      0 0 25px rgb(255, 255, 255),
      0 0 35px rgb(255, 255, 255);
  }
  90% {
    text-shadow:
      0 0 5px rgb(255, 255, 255),
      0 0 10px rgb(255, 255, 255),
      0 0 15px rgb(255, 255, 255),
      0 0 20px rgb(255, 255, 255);
  }
  100% {
    text-shadow:
      0 0 8px rgb(255, 255, 255),
      0 0 15px rgb(255, 255, 255),
      0 0 25px rgb(255, 255, 255),
      0 0 35px rgb(255, 255, 255);
  }
}

@keyframes directGlow {
  0% {
    opacity: 0.5;  /* start dimmer since text goes up */
    filter: blur(9px);
    transform: translateX(-50%) scaleX(1);
  }
  25% {
    opacity: 0.5;   /* still fairly dim at top */
    filter: blur(9px);
    transform: translateX(-50%) scaleX(0.9);
  }
  50% {
    opacity: 0.9;  /* brightest at bottom */
    filter: blur(7px);
    transform: translateX(-50%) scaleX(0.72);
  }
  75% {
    opacity: 0.5;
    filter: blur(9px);
    transform: translateX(-50%) scaleX(0.9);
  }
  100% {
    opacity: 0.5;
    filter: blur(9px);  
    transform: translateX(-50%) scaleX(1);
  }
}

/* media glow canvas - sunlight effect */
.media-glow-canvas {
  transition: opacity 0.3s ease, filter 0.3s ease;
  border-radius: 0;
  opacity: 0.8;
  transform-origin: center center;
  pointer-events: none;
  will-change: filter, opacity, transform;
  box-shadow: 0 0 25px rgba(255, 240, 180, 0.4);
  transform: translateX(-50%) rotate(1.5deg);
  position: absolute;
  top: 17%;
  left: 50%;
  z-index: 11;
  mix-blend-mode: screen;
  display: block;
}

/* SVG styling */
#pvm-svg {
  width: 400px;
  height: auto;
  max-width: 100%;
  pointer-events: auto;
}

/* Dark mode and Light mode merged blocks */
@media (prefers-color-scheme: dark) {
  body {
    background-color: rgb(29, 31, 32);
  }

  h1,
  p {
    color: rgb(255, 255, 255);
  }

  /* text glow in dark mode */
  .message span {
    animation:
      wave 15s ease-in-out infinite,
      glimmer 4s ease-in-out infinite;
    animation-delay: calc(0.08s * var(--char-index, 0) + 0.2s), calc(0.08s * var(--char-index, 0) + 0.2s);
  }

  /* In dark mode: show PVM glow overlays (default behavior) */
  .pvm-glow-reflection {
    background: radial-gradient(ellipse at center,
      rgba(255, 255, 255, 0.75) 0%,
      rgba(255, 255, 255, 0.2) 50%,
      rgba(255, 255, 255, 0) 100%);
    box-shadow: none;
    opacity: 1;
    animation: directGlow 15s ease-in-out infinite;
    display: block;
  }

  /* Dark mode specific styles for footer links */
  .footer-links a {
    color: var(--color-text-light);
  }
  .footer-links a:hover, .footer-links a:focus {
    color: var(--color-text-muted);
  }

  /* apply same hover feel to homepage gallery link in dark mode */
  .message a:hover, .message a:focus {
    color: var(--color-text-muted);
  }

}

@media (prefers-color-scheme: light) {
  .media-glow-canvas {
    filter: saturate(1.2) contrast(1.8) brightness(1.4);
    opacity: 0.85;
    mix-blend-mode: screen;
  }

  .pvm-glow-reflection {
    display: none;
  }

  .pvm-pixi-canvas {
    background-color: rgb(23, 23, 23);
  }

}

/* SVG Power button styles */
#pvm-svg #power {
  fill: none !important;
  stroke: none !important;
  cursor: pointer !important;
  filter: none !important;
  pointer-events: all !important;
}

#pvm-svg #power:hover {
  filter: drop-shadow(0 0 6px white) drop-shadow(0 0 12px white);
  cursor: pointer !important;
}

.pvm-pixi-canvas {
  transition: opacity 0.3s ease;
}

.vignette-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 4;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity 0.3s ease;
  background: radial-gradient(ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.1) 80%,
    rgba(0, 0, 0, 0.3) 90%,
    rgba(0, 0, 0, 0.5) 100%
  );
}

/* On‑screen display (PVM menu) */
.pvm-osd-menu {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  padding: 6% 7%;
  box-sizing: border-box; /* keep padding inside screen bounds */
  color: #eaeaea;
  font-family: 'SonyCam', monospace;
  /* Original menu scale */
  font-size: clamp(9px, 1.6vh, 18px);
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  pointer-events: none; /* display only */
  z-index: 2; /* above video (1), below phosphor (3), vignette (4), scanlines (5), sunlight (11) */
  opacity: 1;
  transition: opacity 0.10s ease; /* symmetric fade in/out */
  /* Distribute main block and footer with equal top/bottom padding */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Crisp black outline for OSD text (instead of single drop shadow) */
.pvm-osd-menu .osd-title,
.pvm-osd-menu .osd-item,
.pvm-osd-menu .osd-foot-text,
.pvm-osd-menu .osd-geom,
.pvm-osd-menu .geom-left,
.pvm-osd-menu .geom-right,
.pvm-osd-menu .geom-input,
.pvm-osd-menu .geom-param,
.pvm-osd-menu .geom-val,
.pvm-osd-menu .geom-sup {
  /* 1px outline using 8-directional shadows; no blur */
  text-shadow:
    1px 0 0 #000,
   -1px 0 0 #000,
    0 1px 0 #000,
    0 -1px 0 #000,
    1px 1px 0 #000,
    1px -1px 0 #000,
   -1px 1px 0 #000,
   -1px -1px 0 #000;
}

/* (removed) CRT fade underlay */
.pvm-osd-menu .osd-title {
  margin-bottom: 1.6em; /* a bit more space before items */
  margin-top: 0;
}
.pvm-osd-menu .osd-list { margin-left: -0.45em; }
.pvm-osd-menu .osd-item { opacity: 0.9; display: grid; grid-template-columns: 1.1em 1fr auto; column-gap: 0.15em; align-items: center; margin: 0; row-gap: 0; }
.pvm-osd-menu .osd-item.selected { opacity: 1; }
.pvm-osd-menu .osd-arrow {
  display: inline-block;
  width: 1.5em; /* room for slightly larger glyph */
  text-align: center;
  vertical-align: middle;
  font-size: 1.65em; /* slightly bigger arrow overall */
  line-height: 0; /* prevent arrow glyph from expanding row height */
  /* nudge slightly down and to the right; keep horizontal squash */
  transform: translate(-0.30em, -0.29em) scaleX(0.55);
}
/* In main menu rows, give the arrow a little breathing room from the text */
.pvm-osd-menu .osd-item .osd-arrow { margin-right: 0.18em; }
.pvm-osd-menu .osd-val {
  grid-column: 3;
  justify-self: end;
  display: inline-block;
  margin-left: 0;
  color: #cfcfcf;
}
.pvm-osd-menu .osd-footer {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 6%;
  display: grid;
  /* Place ENTER near SELECT by collapsing spacer between them */
  grid-template-columns: auto auto 1fr;
  align-items: center;
  font-size: 1em; /* match main OSD font size */
  opacity: 0.9;
}
.pvm-osd-menu.geom-mode .osd-title,
.pvm-osd-menu.geom-mode .osd-footer {
  display: none;
}
.pvm-osd-menu .osd-geom {
  position: relative;
  width: 100%;
  height: 100%;
  padding-top: 5%;
}
.pvm-osd-menu .geom-left {
  position: absolute;
  left: 0;
  top: 0;
}
.pvm-osd-menu .geom-input {
  font-weight: 400; /* match regular menu weight */
}
.pvm-osd-menu .geom-param {
  margin-top: 0.4em;
}
.pvm-osd-menu .geom-right {
  position: absolute;
  right: 7%;
  top: 0;
  text-align: right;
  padding-right: 0; /* do not shift the whole right section */
}
.pvm-osd-menu .geom-write {
  margin-top: 0.25em;
  font-size: 1em; /* same size as other OSD text */
  text-transform: uppercase;
  text-align: right; /* align right edge with star */
  margin-right: 0.74em; /* nudge WRITE slightly left */
}
.pvm-osd-menu .geom-star {
  position: static; /* inline, share baseline with numbers */
  display: inline-block;
  transform: translateY(0.40em); /* lower to match baseline visually */
  font-size: 1.15em; /* make * match letter height visually */
  line-height: 1;
}
.pvm-osd-menu .geom-star-slot {
  display: inline-block;
  width: 1em; /* reserve space so numbers don't shift when star appears */
  text-align: left;
  margin-left: 0.15em; /* fine spacing after index number */
  margin-right: 0.50em; /* move star a bit further left than WRITE */
}
.pvm-osd-menu .geom-arrow { margin-right: 0.4em; display: inline-block; }
.pvm-osd-menu .geom-right .osd-arrow {
  /* pull the arrow closer to the numeric value in geometry view */
  width: 0.85em;
  margin-right: -0.25em;
  /* move arrow itself slightly to the right */
  transform: translate(-0.06em, -0.29em) scaleX(0.55);
}
.pvm-osd-menu .geom-val { display: inline-block; min-width: 2ch; text-align: right; }
.pvm-osd-menu .geom-sup { display: inline-block; margin-left: 0.6em; opacity: 0.9; }
.pvm-osd-menu .osd-foot-left { justify-self: start; }
.pvm-osd-menu .osd-foot-enter { justify-self: start; margin-left: 0.9em; }
.pvm-osd-menu .osd-foot-menu { justify-self: end; }
.pvm-osd-menu .osd-ico { display: inline-block; height: 0.765em; vertical-align: middle; image-rendering: auto; opacity: 0.95; filter: drop-shadow(1px 0 0 #000); }
.pvm-osd-menu .osd-ico-enter { height: 0.861em; }
.pvm-osd-menu .osd-ico-menu { height: 0.797em; }
.pvm-osd-menu .osd-ico-arrows { margin-right: 0.14em; height: 0.893em; }
.pvm-osd-menu .osd-foot-text { margin-left: 0; letter-spacing: 0.08em; }
/* (removed kbd pills; OSD footer uses image icons) */

/* --- page load fade-in --- */

/* Responsive homepage scaling */
@media (max-width: 550px) {
  :root { --pvm-graphic-width: 320px; }
  .home-title { font-size: 2rem; margin: 0.25em 0; }
  .message { margin: 0.5em 0 1em; }
}

/* Accessibility: reduce motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }

  html.home-intro .home-title,
  html.home-intro .pvm-container,
  html.home-intro .message,
  html.home-intro .site-footer {
    opacity: 1;
  }
}
