/* Çağla'nın Televizyonu — Stardew-style login screen.
   Scoped entirely under body.tv-login so it never touches the
   --bg/--fg custom properties or prefers-color-scheme logic in style.css. */

/* html isn't reachable via a body.tv-login descendant selector, but this
   file is only ever linked from login.ejs, so a bare selector here is
   still effectively page-scoped. Locking scroll + using svh (the mobile
   browser UI bar never retracts it) stops the page from shifting when
   Chrome's address bar collapses/expands on scroll. */
html {
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

body.tv-login {
  --tv-sky: #7ebcf7;
  --tv-wood: #5c3d22;
  --tv-wood-dark: #3a2716;
  --tv-parchment: #c69f72;
  --tv-ink: #4a361f;
  --tv-green: #416a2b;
  --tv-green-dark: #2f4d1f;
  --tv-gold: #cf8e24;
  --tv-bg-band: 29.4vh;

  color-scheme: light;
  background: var(--tv-sky);
  color: var(--tv-ink);
  overflow: hidden;
  overscroll-behavior: none;
  height: 100vh;
  height: 100svh;
  margin: 0;
}

.tv-scene {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- animated background ---------- */

.tv-bg {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--tv-bg-band);
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

/* bahce.png's own flower/fence band only occupies the bottom ~43% of the
   source image (the rest is sky); render the track taller than the visible
   band and bottom-align it so the outer overflow:hidden crops away the
   redundant sky instead of squeezing the whole image into the band. */
.tv-bg__track {
  position: absolute;
  left: 0;
  bottom: 0;
  height: calc(var(--tv-bg-band) / 0.43);
  display: flex;
  align-items: flex-end;
  animation: tv-scroll 26s linear infinite;
}

.tv-bg__track img {
  height: 100%;
  width: auto;
  flex: none;
  display: block;
  image-rendering: pixelated;
}

@keyframes tv-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(-1 * var(--tv-tile-w, 0px))); }
}

@media (prefers-reduced-motion: reduce) {
  .tv-bg__track { animation: none; }
  .tv-sign, .tv-poem__lines, .tv-poem__punch, .tv-swap {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ---------- entrance sequence: sign drops in, then poem lines, then punchline, then cassette ---------- */

@keyframes tv-drop-in {
  from { transform: translateY(-140%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes tv-fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- content ---------- */

.tv-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "info"
    "swap";
  justify-items: center;
  align-content: start;
  gap: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 5vw;
  box-sizing: border-box;
}

.tv-info {
  grid-area: info;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.tv-sign {
  width: 100%;
  height: auto;
  display: block;
  opacity: 0;
  transform: translateY(-140%);
}

body.tv-ready .tv-sign {
  animation: tv-drop-in 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.tv-poem {
  text-align: center;
  margin: 3.3vh 0 2.8vh;
  padding: 0;
  width: 108%;
}

.tv-poem__lines {
  font-family: 'Lora', Georgia, serif;
  font-weight: 600;
  font-size: clamp(15px, 4.6vw, 21px);
  line-height: 1.3;
  margin: 0 0 1.2vh;
  color: var(--tv-ink);
  opacity: 0;
  transform: translateY(14px);
}

.tv-poem__punch {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  font-size: clamp(19px, 6.2vw, 28px);
  line-height: 1.15;
  margin: 0;
  color: var(--tv-ink);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(14px);
}

body.tv-ready .tv-poem__lines { animation: tv-fade-up 0.5s ease-out 0.55s both; }
body.tv-ready .tv-poem__punch { animation: tv-fade-up 0.5s ease-out 0.85s both; }

/* cassette + credentials share one grid cell so they can cross-fade */

.tv-swap {
  grid-area: swap;
  position: relative;
  width: 100%;
  margin-bottom: 5.1vh;
  opacity: 0;
  transform: translateY(14px);
}

body.tv-ready .tv-swap { animation: tv-fade-up 0.5s ease-out 1.15s both; }

.tv-cassette {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  transition: opacity .45s ease, transform .45s ease;
}

.tv-cassette img {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
}

.tv-cassette:hover { transform: translateY(-2px); }
.tv-cassette:active { transform: translateY(1px); }

.tv-credentials {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 16px;
  box-sizing: border-box;
  background: var(--tv-parchment);
  border: 4px solid var(--tv-wood);
  border-radius: 10px;
  box-shadow: 0 0 0 2px var(--tv-wood-dark) inset, 0 6px 0 var(--tv-wood-dark);
  opacity: 0;
  transform: translateY(14px) scale(.97);
  pointer-events: none;
  transition: opacity .4s ease, transform .4s ease;
}

.tv-label {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--tv-wood-dark);
  margin: 0 0 -4px;
}

.tv-credentials input {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 3px solid var(--tv-wood);
  background: #fdf6e8;
  color: var(--tv-wood-dark);
  box-sizing: border-box;
  width: 100%;
}

.tv-credentials input:focus {
  outline: 3px solid var(--tv-gold);
  outline-offset: 1px;
}

.tv-submit {
  margin-top: auto;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .02em;
  color: #fff;
  background: var(--tv-green);
  border: 3px solid var(--tv-gold);
  border-radius: 8px;
  padding: 11px 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--tv-green-dark);
}

.tv-submit:active { transform: translateY(2px); box-shadow: none; }

.tv-error {
  margin: 0;
  padding: 8px 10px;
  background: #f4d9d3;
  border: 2px solid #a13d2b;
  color: #7a2a1c;
  border-radius: 6px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
}

/* revealed state: cassette hides, credentials take over */

body.tv-login .tv-cassette {
  opacity: 1;
  transform: none;
}

body.tv-login.is-revealed .tv-cassette {
  opacity: 0;
  transform: translateY(-10px) scale(.97);
  pointer-events: none;
  position: absolute;
  inset: 0;
}

body.tv-login.is-revealed .tv-credentials {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  position: relative;
}

/* ---------- desktop: same stacked layout as mobile (sign, poem, cassette),
   just a wider column and a taller bg band so it doesn't look like a tiny
   phone-shaped column lost in the middle of a big screen ---------- */

@media (min-width: 900px) {
  body.tv-login { --tv-bg-band: 54vh; }

  .tv-content {
    max-width: 560px;
    padding: 4vh 5vw 0;
  }

  .tv-sign {
    max-width: 480px;
  }
}
