/* Kucing TV. Departure Mono (OFL) for everything on the TV, IBM Plex Mono for the page below. */
@font-face {
  font-family: "Departure Mono";
  src: url("https://cdn.jsdelivr.net/gh/rektdeckard/departure-mono@v1.500/public/assets/DepartureMono-Regular.woff2") format("woff2");
  font-display: swap;
}

:root {
  --screen: #eaeaea;      /* the TV picture: the cat's light grey */
  --room: #0e0e0e;        /* bezel and room around the TV */
  --panel: #1a1a1a;
  --ink: #0d0d0d;
  --ink-2: #3a3a3a;
  --ink-3: #6b6b6b;
  --paper: #eaeaea;       /* the page below the TV */
  --accent: #e0362c;      /* one accent, on actions only (house rule 16) */
  --pixel: "Departure Mono", "Courier New", monospace;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1); /* transitions.dev --ease-smooth-out */
  --gutter: clamp(16px, 3vw, 40px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.6 var(--mono); -webkit-font-smoothing: antialiased; }
p, h1, h2, ol, ul { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.px { display: inline-block; line-height: 0; }
.px svg { width: 100%; height: 100%; }
/* English subtitles under the Malay line, everywhere */
.en { display: block; font-family: var(--mono); font-size: 0.72em; font-weight: 400; letter-spacing: 0; text-transform: none; opacity: 0.75; }

/* ---------- the TV: the whole first screen ---------- */
.tv {
  height: 100svh; min-height: 520px;
  display: grid; grid-template-rows: 1fr auto;
  padding: clamp(10px, 1.6vw, 22px) clamp(10px, 1.6vw, 22px) 0;
  background: var(--room);
  position: relative;
}
.picture {
  position: relative; overflow: hidden; cursor: pointer;
  border-radius: clamp(18px, 3vw, 44px) / clamp(16px, 2.6vw, 38px); /* a CRT's soft rounded corners */
  background: #050505;
}
.screen { position: absolute; inset: 0; background: var(--screen); transform-origin: 50% 50%; }
.cat-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* glass: vignette and a faint line texture over everything on the picture */
.glass {
  position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.035) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse 75% 70% at 50% 48%, transparent 62%, rgba(0, 0, 0, 0.32) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), inset 0 0 60px rgba(0, 0, 0, 0.35);
}

/* channel overlays: one shows at a time */
.channel { display: none; position: absolute; inset: 0; pointer-events: none; font-family: var(--pixel); }
.tv[data-ch="0"] [data-for="0"], .tv[data-ch="1"] [data-for="1"], .tv[data-ch="2"] [data-for="2"],
.tv[data-ch="3"] [data-for="3"], .tv[data-ch="4"] [data-for="4"] { display: block; }
[data-subs] > [hidden] { display: none; }
.tv.tuning .channel { visibility: hidden; } /* static covers the channel graphics too */

/* channel bug (top left) and the channel number (top right) */
.bug { position: absolute; top: clamp(14px, 2.4vw, 30px); left: clamp(16px, 2.6vw, 34px); font-family: var(--pixel); color: var(--ink); pointer-events: none; }
.bug h1 { font-size: clamp(16px, 1.5vw, 22px); font-weight: 400; display: flex; align-items: center; gap: 0.5em; }
.bug .logo { background: var(--ink); color: var(--screen); padding: 0.1em 0.35em; letter-spacing: 0.04em; }
.bug p { margin-top: 6px; font-size: 11px; line-height: 1.4; color: var(--ink-3); }
.tv[data-ch="4"] .bug { color: #f1f1f1; }
.tv[data-ch="4"] .bug .logo { background: #f1f1f1; color: #0d0d0d; }
.tv[data-ch="4"] .bug p { color: #a8a8a8; }
.osd {
  position: absolute; top: clamp(14px, 2.4vw, 30px); right: clamp(16px, 2.6vw, 34px);
  font: 400 clamp(18px, 2vw, 30px)/1 var(--pixel); color: #fff;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  opacity: 0; transition: opacity 350ms var(--ease-out); pointer-events: none; /* hides like a toast closes */
}
.osd.show { opacity: 1; transition-duration: 80ms; }

/* CH 0: test card */
.testcard { background: var(--screen); }
.bars { position: absolute; inset: 0 0 32%; display: grid; grid-template-columns: repeat(7, 1fr); }
.bars i { display: block; }
.bars i:nth-child(1) { background: #f4f4f4; } .bars i:nth-child(2) { background: #d0d0d0; }
.bars i:nth-child(3) { background: #ababab; } .bars i:nth-child(4) { background: #858585; }
.bars i:nth-child(5) { background: #5e5e5e; } .bars i:nth-child(6) { background: #383838; }
.bars i:nth-child(7) { background: #141414; }
.nosignal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--ink); color: #f1f1f1; padding: 22px 30px 18px; text-align: center; }
.nosignal .px { width: 42px; height: 42px; margin-bottom: 12px; }
.nosignal .big { font-size: clamp(22px, 3vw, 40px); letter-spacing: 0.04em; }
.nosignal .sub { font: 400 13px/1.4 var(--mono); opacity: 0.7; margin-top: 4px; }

/* CH 1: news lower-third and ticker */
.lower-third { position: absolute; left: clamp(16px, 4vw, 64px); right: clamp(16px, 4vw, 64px); bottom: clamp(52px, 7.5vh, 76px); }
.lower-third .tag { display: inline-block; background: var(--screen); color: var(--ink); border: 2px solid var(--ink); border-bottom: 0; padding: 4px 10px; font-size: 13px; }
.lower-third .tag span { font-family: var(--mono); font-size: 11px; opacity: 0.7; }
.headline { background: var(--ink); color: #f6f6f6; padding: 12px 16px; font-size: clamp(16px, 1.9vw, 26px); line-height: 1.25; min-height: 3.6em; }
.headline .en { margin-top: 4px; }
.ticker { position: absolute; left: 0; right: 0; bottom: 0; height: clamp(34px, 5vh, 46px); display: flex; align-items: center; background: #f6f6f6; border-top: 2px solid var(--ink); color: var(--ink); overflow: hidden; }
.ticker-label { flex: none; align-self: stretch; display: flex; align-items: center; padding: 0 14px; background: var(--ink); color: #f6f6f6; font-size: 14px; position: relative; z-index: 1; }
.ticker-track { flex: 1; overflow: hidden; white-space: nowrap; font-size: clamp(13px, 1.3vw, 16px); }
.ticker-track p { display: inline-block; padding-left: 100%; animation: ticker 48s linear infinite; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-100%); } }

/* CH 2: weather card */
.wx-card { position: absolute; right: clamp(16px, 3.5vw, 56px); top: 50%; transform: translateY(-50%); width: min(360px, 34vw); background: rgba(13, 13, 13, 0.92); color: #f1f1f1; padding: 16px 18px 14px; }
.wx-title { font-size: 15px; margin-bottom: 10px; }
.wx-title span { font-family: var(--mono); font-size: 11px; opacity: 0.7; }
.wx-card ul { list-style: none; padding: 0; display: grid; gap: 10px; }
.wx-card li { display: grid; grid-template-columns: 22px 1fr auto; column-gap: 10px; align-items: start; }
.wx-card li .px { width: 20px; height: 28px; margin-top: 2px; }
.wx-card li b { font-weight: 400; font-size: 15px; }
.wx-card li .t { font-size: 20px; line-height: 1; }
.wx-card li .m { grid-column: 2 / 4; font-family: var(--mono); font-size: 12px; line-height: 1.35; opacity: 0.9; }
.label { font: 400 10px/1.3 var(--mono); opacity: 0.6; margin-top: 10px; }

/* CH 3: shopping */
.burst {
  position: absolute; left: clamp(16px, 5vw, 80px); top: 26%; width: clamp(150px, 15vw, 210px); aspect-ratio: 1;
  display: grid; place-content: center; text-align: center; background: var(--ink); color: #f6f6f6;
  clip-path: polygon(50% 0, 61% 18%, 82% 10%, 79% 32%, 100% 40%, 84% 55%, 96% 75%, 73% 76%, 68% 98%, 50% 84%, 32% 98%, 27% 76%, 4% 75%, 16% 55%, 0 40%, 21% 32%, 18% 10%, 39% 18%);
  transform: rotate(-8deg);
}
.burst span { font-size: 14px; }
.burst b { font-weight: 400; font-size: clamp(26px, 2.8vw, 38px); line-height: 1.05; }
.shop-card { position: absolute; right: clamp(16px, 4vw, 64px); bottom: clamp(18px, 4vh, 40px); width: min(380px, 36vw); background: var(--screen); border: 3px solid var(--ink); padding: 14px 16px; color: var(--ink); }
.shop-card .product { font-size: clamp(18px, 1.8vw, 24px); line-height: 1.2; }
.shop-card .deal { margin-top: 10px; font-size: 14px; }
.shop-card .deal b { font-weight: 400; background: var(--ink); color: #f6f6f6; padding: 0 6px; }
.shop-card .call { margin-top: 10px; font-size: 16px; }

/* CH 4: documentary letterbox */
.letterbox { position: absolute; left: 0; right: 0; background: #0b0b0b; color: #f1f1f1; }
.letterbox.top { top: 0; height: 13%; }
.letterbox.bottom { bottom: 0; height: 17%; display: grid; place-items: center; text-align: center; padding: 0 var(--gutter); }
/* centred in the top letterbox: the channel logo has the left corner, the channel number the right */
.doc-title { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; font-size: 13px; text-align: center; white-space: nowrap; opacity: 0.85; }
.subs p { font: 500 clamp(15px, 1.6vw, 21px)/1.35 var(--mono); }

/* ---------- power off: the picture folds to a line, then a dot ---------- */
.tv.off .screen { animation: tv-off 420ms var(--ease-out) forwards; }
.tv.off .picture::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 18px 6px rgba(255, 255, 255, 0.5); animation: dot 900ms 380ms ease-out forwards; opacity: 0;
}
.tv.off .bug, .tv.off .osd { visibility: hidden; }
@keyframes tv-off {
  0% { transform: scale(1, 1); filter: brightness(1); }
  55% { transform: scale(1, 0.006); filter: brightness(3); }
  100% { transform: scale(0, 0.006); filter: brightness(3); }
}
@keyframes dot { 0% { opacity: 1; } 100% { opacity: 0; } }
.tv.waking .screen { animation: tv-on 250ms var(--ease-out); } /* only after power on, never on load */
@keyframes tv-on { from { transform: scale(1, 0.006); filter: brightness(3); } to { transform: scale(1, 1); filter: brightness(1); } }
.tv.no-cat .cat-canvas { display: none; }

/* ---------- the TV's front panel: the remote ---------- */
.panel { display: flex; align-items: center; gap: 18px; padding: 12px 6px 14px; color: #9a9a9a; font: 400 12px/1 var(--pixel); }
.remote { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.remote .nums { display: flex; gap: 6px; }
.remote button {
  font: 400 14px/1 var(--pixel); min-width: 40px; height: 36px; padding: 0 10px; cursor: pointer;
  color: #f1f1f1; background: var(--panel); border: 1px solid #3a3a3a; border-radius: 4px;
  transition: transform 120ms var(--ease-out), background-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}
.remote button.power { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 16px; }
.remote button.power[aria-pressed="false"] { background: transparent; color: var(--accent); }
.remote button[aria-pressed="true"]:not(.power) { border-color: var(--accent); color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.remote button:active { transform: scale(0.96); }
.remote button:focus-visible, .to-guide:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.slots a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .remote button:hover { border-color: #6a6a6a; }
  .remote button.power:hover { filter: brightness(1.1); }
}
.keys { margin-left: auto; }
.panel { position: relative; }
/* Kongsi: an action, so it carries the accent (house rule 16) */
.share {
  font: 400 14px/1 var(--pixel); height: 36px; padding: 0 14px; cursor: pointer; border-radius: 4px;
  color: #fff; background: transparent; border: 1px solid var(--accent);
  transition: transform 120ms var(--ease-out), background-color 160ms var(--ease-out);
}
.share:active { transform: scale(0.96); }
.share:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .share:hover { background: var(--accent); } }
.share-note {
  position: absolute; right: 6px; bottom: calc(100% + 8px); max-width: min(420px, 90vw); padding: 8px 12px;
  background: #f1f1f1; color: var(--ink); font: 400 12px/1.3 var(--pixel); word-break: break-all; user-select: all;
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.share-note.show { opacity: 1; transform: none; pointer-events: auto; transition-duration: 250ms; }
.keys span { font-family: var(--mono); }
.to-guide { color: #d8d8d8; text-decoration: none; border-bottom: 1px solid #555; padding-bottom: 2px; }

/* ---------- below the TV: the channel's own pages ---------- */
.wrap { width: min(880px, 100% - 2 * var(--gutter)); margin: 0 auto; }
.guide { padding: clamp(56px, 8vw, 96px) 0 40px; }
.guide h2, .about h2 { font: 400 clamp(26px, 3.2vw, 40px)/1.1 var(--pixel); margin-bottom: 26px; }
.guide h2 .en, .about h2 .en { font-size: 14px; margin-top: 8px; }
.slots { list-style: none; padding: 0; border-top: 2px solid var(--ink); }
.slots li { display: grid; grid-template-columns: 80px 1fr auto; gap: 18px; align-items: baseline; padding: 16px 0; border-bottom: 1px solid #c4c4c4; }
.slots time { font: 400 18px/1 var(--pixel); }
.slots .show { font-weight: 500; }
.slots .show .en { font-size: 13px; color: var(--ink-3); opacity: 1; margin-top: 2px; }
.slots a { color: var(--accent); font: 400 14px/1 var(--pixel); text-decoration: none; white-space: nowrap; padding: 8px 0; }
@media (hover: hover) and (pointer: fine) { .slots a:hover { text-decoration: underline; text-underline-offset: 4px; } }
.about { padding: 40px 0 72px; }
.about p { max-width: 62ch; margin-bottom: 14px; }
.about p .en { font-size: 13px; color: var(--ink-3); opacity: 1; margin-top: 2px; }
/* ---------- footer: the TV's room again, an oversized scanline wordmark at the bottom ---------- */
.foot { background: var(--room); color: #cfcfcf; padding: clamp(48px, 6vw, 80px) var(--gutter) 0; overflow: hidden; }
.foot-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(24px, 4vw, 64px); max-width: 1200px; margin: 0 auto; }
.foot h2 { font: 400 15px/1.2 var(--pixel); color: #f1f1f1; margin-bottom: 14px; }
.foot h2 .en { font-size: 11px; color: #8a8a8a; opacity: 1; margin-top: 4px; }
.foot ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.foot-col a { color: #cfcfcf; text-decoration: none; }
.foot-col a, .to-top { transition: color 160ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .foot-col a:hover, .to-top:hover { color: #fff; text-decoration: underline; text-underline-offset: 4px; } }
.foot a:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.clock { font: 400 clamp(34px, 4vw, 52px)/1 var(--pixel); color: #f1f1f1; letter-spacing: 0.02em; }
.onair { margin-top: 10px; font-size: 14px; color: #e6e6e6; }
.onair .en { font-size: 12px; color: #8a8a8a; opacity: 1; margin-top: 2px; }
.keys-list { font-size: 13px; }
kbd { font: 400 12px/1 var(--pixel); display: inline-block; min-width: 1.7em; padding: 3px 5px; text-align: center; border: 1px solid #4a4a4a; border-radius: 3px; color: #f1f1f1; }
.to-top { display: inline-block; margin-top: 18px; color: #f1f1f1; font: 400 13px/1 var(--pixel); text-decoration: none; border-bottom: 1px solid #555; padding-bottom: 3px; }
/* the wordmark is drawn as scanlines, like the cat: ink lines with gaps, clipped to the letters */
.wordmark {
  margin: clamp(40px, 6vw, 72px) calc(-1 * var(--gutter)) 0; text-align: center; white-space: nowrap;
  font: 400 min(16vw, 300px)/0.82 var(--pixel); letter-spacing: -0.02em; /* fits the width at any size, glyph overhang included */
  color: transparent; -webkit-background-clip: text; background-clip: text;
  background-image: repeating-linear-gradient(to bottom, #ededed 0 0.024em, transparent 0.024em 0.04em);
  user-select: none;
}
.foot-bottom {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  max-width: 1200px; margin: 0 auto; padding: 18px 0 22px; border-top: 1px solid #2c2c2c;
  font-size: 12px; color: #8a8a8a;
}
.credit { display: flex; align-items: center; gap: 12px; color: #a8a8a8; text-decoration: none; font: 400 12px/1 var(--pixel); flex: none; }
/* the logo GIF has a white background, so it sits on a small white plate; the picture is a window
   onto the logo's own area of the GIF (x 32-476, y 80-266 of 506 x 337, across all frames) */
.credit-plate { display: block; background: #fff; border-radius: 6px; padding: 8px 12px; line-height: 0; }
.credit-logo { display: block; position: relative; overflow: hidden; width: 150px; aspect-ratio: 444 / 186; }
.credit-logo img { position: absolute; width: calc(100% * 506 / 444); height: auto; left: calc(-100% * 32 / 444); top: calc(-100% * 80 / 186); }
@media (hover: hover) and (pointer: fine) { .credit:hover span { color: #fff; } }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .panel { flex-wrap: wrap; gap: 10px; padding: 10px 0 12px; }
  .remote { width: 100%; justify-content: space-between; }
  .remote button { min-width: 0; height: 40px; padding: 0 9px; }
  .remote .nums { gap: 4px; }
  .keys { display: none; }
  .to-guide { margin-left: 0; }
  .share { margin-left: auto; height: 40px; }
  .lower-third { bottom: 48px; }
  .headline { font-size: 15px; min-height: 0; }
  .wx-card { left: 12px; right: 12px; top: auto; bottom: 12px; transform: none; width: auto; padding: 12px 14px; }
  .wx-card ul { grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .wx-card li .m { display: none; }
  .burst { top: 16%; left: 12px; width: 120px; }
  .burst b { font-size: 22px; }
  .shop-card { left: 12px; right: 12px; width: auto; bottom: 12px; }
  .letterbox.top { height: 19%; }
  .doc-title { left: 16px; right: auto; transform: none; text-align: left; white-space: normal; bottom: 10px; }
  .slots li { grid-template-columns: 60px 1fr; }
  .slots a { grid-column: 2; padding: 4px 0 0; }
  .foot-top { grid-template-columns: 1fr; gap: 32px; }
  .foot-bottom { flex-direction: column; align-items: flex-start; }
  .credit-logo { width: 124px; }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track p { animation: none; padding-left: 0; }
  .tv.off .screen, .tv.waking .screen, .tv.off .picture::after { animation: none; }
  .tv.off .screen { transform: scale(0); }
  .osd { transition: none; }
}
