/* ============================================================
 * TPS Live Streaming — STYLE
 * Theme matches www.tharnpanya.com (navy #0b2a4a / gold #c89b3c)
 * Mobile-first · Smart-TV friendly · no heavy animations
 * ============================================================ */
:root {
  --navy: #0b2a4a;
  --navy-soft: #123f6d;
  --gold: #c89b3c;
  --gold-soft: #f5e8c7;
  --surface: #ffffff;
  --canvas: #eef2f6;
  --ink: #142033;
  --muted: #64748b;
  --red: #e11d2f;
  --green: #15803d;
  --orange: #ea580c;
  --fb: #1877f2;
  --yt: #ff0000;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(11, 42, 74, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Noto Sans Thai", Tahoma, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(200, 155, 60, .12), transparent 28rem),
    linear-gradient(180deg, #f7f9fc 0%, var(--canvas) 100%);
  background-attachment: fixed;
  line-height: 1.6;
}
img { max-width: 100%; }
a { color: var(--navy-soft); }

/* ---------- HEADER ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 6px 24px rgba(11, 42, 74, .25);
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: .7rem 1rem;
  display: flex;
  align-items: center;
  gap: .9rem;
}
.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--navy);
  font-size: .95rem;
  flex: none;
  overflow: hidden;
  padding: 3px;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-names { line-height: 1.25; }
.brand-th { color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand-en { color: var(--gold-soft); font-size: .78rem; }

.main-nav { margin-left: auto; display: none; }
.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: .5rem .9rem;
  border-radius: 10px;
  color: #dbe7f5;
  text-decoration: none;
  font-size: .92rem;
}
.main-nav a:hover, .main-nav a:focus-visible { background: var(--navy-soft); color: #fff; outline: none; }
.main-nav a.nav-live { background: var(--gold); color: var(--navy); font-weight: 700; }

.menu-toggle {
  margin-left: auto;
  min-width: 48px;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: transparent;
  color: #fff;
  border-radius: 10px;
  font-size: 1.25rem;
  cursor: pointer;
}
.menu-toggle:focus-visible { outline: 3px solid var(--gold); }

/* ---------- HERO ---------- */
.hero {
  position: relative;
  padding: 2.6rem 1rem 2.2rem;
  text-align: center;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(5, 25, 48, .88), rgba(9, 34, 62, .94)),
    var(--navy);
  overflow: hidden;
}
.hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
  opacity: .5;
}
.hero::after {
  content: "";
  position: absolute;
  bottom: -70px; left: 50%;
  width: 340px; height: 140px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(200, 155, 60, .28), transparent 70%);
  pointer-events: none;
}
.hero h1 { margin: .3rem 0; font-size: 1.5rem; }
.hero .hero-en { color: var(--gold-soft); font-size: .95rem; margin: 0 0 .4rem; }
.hero .hero-sub { color: #c9d8ea; font-size: .9rem; margin: 0; }

/* ---------- LAYOUT ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 1rem; }
.grid-main { display: grid; grid-template-columns: 1fr; gap: 1.2rem; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem;
  border-top: 3px solid var(--gold);
}

/* ---------- PLAYER ---------- */
.player-shell { padding: 0; overflow: hidden; }
.player-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .8rem 1rem;
  flex-wrap: wrap;
}
.player-head h2 { margin: 0; font-size: 1.05rem; color: var(--navy); }
.player-head .sub-en { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: .72rem;
  letter-spacing: .08em;
  padding: .25rem .6rem;
  border-radius: 999px;
}
.live-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }

.video-box { position: relative; background: #000; aspect-ratio: 16 / 9; }
.video-box video { width: 100%; height: 100%; display: block; object-fit: contain; }

.live-waiting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  color: #cbd5e1;
  background: linear-gradient(180deg, rgba(2, 12, 24, .85), rgba(2, 12, 24, .95));
  text-align: center;
  padding: 1rem;
}
.live-waiting .pulse {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  border-top-color: transparent;
  animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.big-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 84px; height: 84px;
  border-radius: 50%;
  border: none;
  background: rgba(200, 155, 60, .95);
  color: var(--navy);
  font-size: 2rem;
  cursor: pointer;
  display: none;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
.big-play:focus-visible { outline: 4px solid #fff; }

.player-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .8rem;
  flex-wrap: wrap;
}
.player-bar button {
  min-width: 52px;
  min-height: 48px;
  border: 1px solid #d7dfeb;
  background: #f6f8fb;
  border-radius: 10px;
  font-size: 1.05rem;
  cursor: pointer;
  color: var(--navy);
}
.player-bar button:hover, .player-bar button:focus-visible { border-color: var(--gold); background: var(--gold-soft); outline: none; }
.stream-status { display: flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--muted); margin-left: auto; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; flex: none; }
.live-dot.st-live { background: var(--green); }
.live-dot.st-connecting { background: var(--gold); animation: blink 1s steps(2) infinite; }
.live-dot.st-offline { background: #94a3b8; }
@keyframes blink { 50% { opacity: .3; } }
.tech-note { width: 100%; font-size: .78rem; color: var(--muted); margin: 0; }

/* ---------- SCHEDULE ---------- */
.section-title { color: var(--navy); font-size: 1.1rem; margin: 0 0 .3rem; }
.section-title .sub-en { font-size: .75rem; color: var(--muted); font-weight: 400; display: block; }
.sch-wrap { overflow-x: auto; }
table.sch { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.sch th {
  background: var(--navy);
  color: #fff;
  text-align: left;
  padding: .6rem .7rem;
  font-weight: 600;
}
table.sch td { padding: .6rem .7rem; border-bottom: 1px solid #e6ebf2; }
table.sch tr.sch-today td { background: var(--gold-soft); }
.sch-status { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.sch-status.sch-live { background: #fee2e2; color: var(--red); }
.sch-status.sch-upcoming { background: #e0f2fe; color: #0369a1; }
.sch-status.sch-done { background: #e5e7eb; color: #4b5563; }

/* mobile card layout for table */
@media (max-width: 640px) {
  table.sch, table.sch tbody, table.sch tr, table.sch td { display: block; width: 100%; }
  table.sch thead { display: none; }
  table.sch tr {
    background: #fbfcfe;
    border: 1px solid #e6ebf2;
    border-radius: 12px;
    margin-bottom: .6rem;
    padding: .3rem 0;
  }
  table.sch tr.sch-today { border-color: var(--gold); background: #fffbeb; }
  table.sch td { border: none; padding: .25rem .9rem; }
  table.sch td::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: var(--muted);
    font-size: .78rem;
  }
}

/* ---------- QUICK ACCESS ---------- */
.quick-grid { display: grid; grid-template-columns: 1fr; gap: .8rem; }
.quick-btn {
  display: flex;
  align-items: center;
  gap: .9rem;
  min-height: 76px;
  padding: .8rem 1rem;
  border-radius: var(--radius);
  color: #fff;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  box-shadow: var(--shadow);
}
.quick-btn .q-icon { font-size: 1.6rem; width: 48px; text-align: center; flex: none; }
.quick-btn .q-title { font-weight: 700; font-size: 1rem; }
.quick-btn .q-sub { font-size: .78rem; opacity: .9; display: block; }
.quick-btn:focus-visible { outline: 4px solid var(--navy); }
.q-vlc { background: linear-gradient(135deg, #f97316, var(--orange)); }
.q-yt  { background: linear-gradient(135deg, #ff4d4d, var(--yt)); }
.q-fb  { background: linear-gradient(135deg, #4b9bff, var(--fb)); }
.q-qr  { background: linear-gradient(135deg, #22c55e, var(--green)); }
.q-guide { background: linear-gradient(135deg, #8b5cf6, #4f46e5); }
.copy-btn {
  margin-left: auto;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, .55);
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border-radius: 10px;
  padding: 0 .8rem;
  cursor: pointer;
  font-family: inherit;
  font-size: .8rem;
}
.copy-btn:focus-visible { outline: 3px solid #fff; }

/* ---------- QR SECTION ---------- */
.qr-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.qr-item { text-align: center; min-width: 0; }
.qr-item .qr-box {
  display: inline-block;
  padding: .5rem;
  background: #fff;
  border: 1px solid #e6ebf2;
  border-radius: 12px;
  max-width: 100%;
  overflow: hidden;
}
.qr-item img, .qr-item canvas { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.qr-item p { margin: .4rem 0 0; font-size: .82rem; color: var(--muted); }

/* ---------- FALLBACK (mixed-content / HTTPS block) ---------- */
.stream-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(2, 12, 24, .92), rgba(2, 12, 24, .97));
  color: #fff;
  text-align: center;
  padding: 1.5rem;
  overflow-y: auto;
}
.fallback-inner { max-width: 440px; }
.fallback-icon { font-size: 3rem; margin-bottom: .4rem; }
.fallback-inner h3 { margin: 0 0 .5rem; font-size: 1.2rem; color: var(--gold-soft); }
.fallback-msg { font-size: .92rem; color: #cbd5e1; margin: 0 0 1rem; }
.fallback-btn {
  display: inline-block;
  min-width: 200px;
  min-height: 48px;
  padding: .7rem 1.2rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), #d4a24c);
  color: var(--navy);
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(200, 155, 60, .35);
}
.fallback-btn:hover, .fallback-btn:focus-visible { box-shadow: 0 6px 24px rgba(200, 155, 60, .55); outline: none; transform: translateY(-1px); }
.fallback-alt { margin-top: 1rem; display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.fallback-alt a {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .5rem .9rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
}
.fallback-alt a { background: rgba(255, 255, 255, .18); }
.fallback-alt a.yt { background: var(--yt); }
.fallback-alt a.fb { background: var(--fb); }
.fallback-alt a:hover, .fallback-alt a:focus-visible { opacity: .85; outline: none; }


/* ---------- INSTRUCTIONS ---------- */
.tips { list-style: none; margin: 0; padding: 0; }
.tips li {
  padding: .55rem 0 .55rem 2rem;
  border-bottom: 1px dashed #e6ebf2;
  position: relative;
  font-size: .9rem;
}
.tips li::before { content: "✓"; position: absolute; left: .3rem; color: var(--green); font-weight: 800; }

/* ---------- FOOTER ---------- */
.site-footer {
  background: var(--navy);
  color: #c9d8ea;
  text-align: center;
  padding: 1.6rem 1rem 2rem;
  border-top: 3px solid var(--gold);
  margin-top: 1.4rem;
  font-size: .85rem;
}
.site-footer .foot-quote { color: var(--gold-soft); font-weight: 600; margin: .4rem 0 .8rem; }
.site-footer a { color: #fff; margin: 0 .5rem; text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--gold); }

/* ---------- ANCHOR OFFSET ----------
   เมนูหลักเป็น sticky สูง ~79px การกดลิงก์ในเมนูจะเลื่อนไปจนหัวข้อ
   ถูกเมนูบัง หากไม่เว้นระยะ scroll-margin-top ไว้ */
[id] { scroll-margin-top: 5.5rem; }

/* ---------- BREAKPOINTS ---------- */
@media (min-width: 480px) {
  .hero h1 { font-size: 1.8rem; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
  .grid-main { grid-template-columns: 1fr; }
  .qr-grid { grid-template-columns: repeat(4, 1fr); }
  .hero h1 { font-size: 2.1rem; }
}
@media (min-width: 1024px) {
  .menu-toggle, .mobile-menu { display: none !important; }
  .main-nav { display: flex; }
  /* Desktop: player left, schedule right */
  .grid-main { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }
  .hero { padding: 3.2rem 1rem 2.6rem; }
}
@media (min-width: 1440px) {
  .wrap { max-width: 1280px; }
}
@media (min-width: 1920px) {
  /* Smart TV 55": scale everything up, keep 16:9-friendly */
  html { font-size: 20px; }
  .wrap { max-width: 1560px; }
  .hero h1 { font-size: 2.6rem; }
  .player-bar button { min-width: 64px; min-height: 56px; font-size: 1.2rem; }
  .main-nav a { font-size: 1.05rem; min-height: 52px; }
}

/* Mobile menu */
.mobile-menu {
  display: none;
  background: var(--navy-soft);
  border-top: 1px solid rgba(255, 255, 255, .15);
}
.mobile-menu.open { display: block; }
.mobile-menu a {
  display: block;
  min-height: 52px;
  padding: .9rem 1.2rem;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  font-size: 1rem;
}
.mobile-menu a:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }

/* Keyboard / remote focus visibility (Smart TV) */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
