/*
 * LayarKita — Telegram Mini App
 *
 * Direction: true-black-flat (seed 201740342).
 * One ground, elevation by lightness alone, one hue on data only.
 * The amber is the product's face: it marks episode progress and the one
 * active selection, never chrome.
 */

:root {
  --ground: #000000;
  --surface: #111111;
  --raised: #1c1c1c;
  --raised-2: #2a2a2a;
  --border: #1a1a1a;
  --rule: #161616;

  --text: #ffffff;
  --muted: #b4b4b4;
  --faint: #949494;

  --accent: #f2b33d;
  --accent-ink: #1a1204;
  --accent-dim: #4a3714;

  --positive: #f2b33d;
  --negative: #e5566f;

  --radius-card: 20px;
  --radius-poster: 10px;
  --radius-control: 999px;

  --gap: 14px;
  --pad: 16px;
  --control-height: 44px;
  --row-height: 56px;

  --fs-title: 22px;
  --fs-section: 16px;
  --fs-body: 14px;
  --fs-small: 12px;

  --font: "Inter", system-ui, -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

button { font: inherit; color: inherit; }

.num { font-variant-numeric: tabular-nums; }

/* A screen-reader-only helper, not a rule. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- shell */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Room for the fixed tab bar plus the home indicator inset. */
  padding-bottom: calc(74px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) var(--pad) 10px;
  background: var(--ground);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  flex: none;
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: 0;
  cursor: pointer;
  text-decoration: none;
  color: var(--muted);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-control);
  background: var(--raised-2);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  object-fit: cover;
}

/* --------------------------------------------------------------- bottom */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  padding: 6px 4px calc(6px + var(--safe-bottom));
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  text-decoration: none;
  color: var(--faint);
  font-size: 11px;
  background: none;
  border: 0;
  cursor: pointer;
}
.tab-on { color: var(--text); }
.tab-dot {
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: transparent;
}
.tab-on .tab-dot { background: var(--accent); }

/* --------------------------------------------------------------- layout */

.page { padding: 0 var(--pad); display: flex; flex-direction: column; gap: 28px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title {
  font-size: var(--fs-section);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.section-link {
  color: var(--muted);
  font-size: var(--fs-small);
  text-decoration: none;
  white-space: nowrap;
}
.section-link:hover { color: var(--text); }

/* ----------------------------------------------------------------- hero */

.hero {
  position: relative;
  margin: 0 calc(var(--pad) * -1);
  overflow: hidden;
  background: var(--surface);
}

.hero-art {
  position: relative;
  aspect-ratio: 16 / 13;
  overflow: hidden;
}

.hero-art img { width: 100%; height: 100%; object-fit: cover; display: block; }

.hero-scrim {
  position: absolute;
  inset: 0;
  /* A neutral scrim over the artwork, so the title stays legible on any image. */
  background: linear-gradient(to top, var(--surface) 4%, rgba(17, 17, 17, 0.72) 38%, rgba(17, 17, 17, 0) 74%); /* taste-skill-ignore */
}

/* The title block sits over the lower part of the artwork, on the scrim. */
.hero-body {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: 18px;
}

.hero-title {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hero-meta {
  color: var(--muted);
  font-size: var(--fs-small);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.hero-meta .sep { color: var(--faint); }

.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-height);
  padding: 0 22px;
  border-radius: var(--radius-control);
  border: 0;
  background: var(--text);
  color: #000000;
  font-size: var(--fs-body);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #e6e6e6; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { background: var(--raised-2); color: var(--faint); cursor: not-allowed; }

.btn-secondary {
  background: var(--raised-2);
  color: var(--text);
}
.btn-secondary:hover { background: #333333; }

.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 16px; font-size: var(--fs-small); }

/* ---------------------------------------------------------------- cards */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 14px 12px;
}

.card { display: block; text-decoration: none; color: inherit; }

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-poster);
  overflow: hidden;
  background: var(--raised);
}

.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }

.poster-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #ffffff;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  max-width: calc(100% - 12px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 2;
}

.poster-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2;
}
.poster-progress span { display: block; height: 100%; background: var(--accent); }

.card-title {
  font-size: 12px;
  font-weight: 500;
  margin: 7px 0 2px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta { font-size: 11px; color: var(--faint); margin: 0; }

/* ---------------------------------------------------------------- rail */

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 128px;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 4px;
  margin: 0 calc(var(--pad) * -1);
  padding-left: var(--pad);
  padding-right: var(--pad);
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; }

/* --------------------------------------------------------------- chips */

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--muted);
  border: 0;
  font-size: var(--fs-small);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip:hover { background: var(--raised); color: var(--text); }
.chip-on { background: var(--raised-2); color: var(--text); }

/* --------------------------------------------------------------- panels */

.panel {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 18px;
}

.panel-title {
  font-size: var(--fs-section);
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.panel-note { color: var(--muted); font-size: var(--fs-small); margin: 0; }

/* -------------------------------------------------------------- detail */

.detail-art {
  position: relative;
  margin: 0 calc(var(--pad) * -1);
  aspect-ratio: 4 / 5;
  overflow: hidden;
}
.detail-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-art::after {
  content: "";
  position: absolute;
  inset: 0;
  /* A neutral scrim over the artwork, so the title stays legible on any image. */
  background: linear-gradient(to top, var(--ground) 3%, rgba(0, 0, 0, 0.55) 42%, rgba(0, 0, 0, 0) 76%); /* taste-skill-ignore */
}

.detail-body { margin-top: -96px; position: relative; padding: 0 var(--pad); }

.detail-title {
  font-size: var(--fs-title);
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.detail-meta { color: var(--muted); font-size: var(--fs-small); margin: 0 0 12px; }

.chips-genre { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip-genre {
  background: var(--raised);
  color: var(--muted);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
}

.detail-actions { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }

/* ------------------------------------------------------------ episodes */

.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
}

.ep {
  min-height: 42px;
  border-radius: 8px;
  background: var(--raised);
  color: var(--muted);
  border: 0;
  display: grid;
  place-items: center;
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.ep:hover { background: var(--raised-2); color: var(--text); }
.ep-on { background: var(--text); color: #000000; font-weight: 600; }

/* -------------------------------------------------------------- player */

.player-stage {
  background: #000000;
  aspect-ratio: 16 / 9;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.player-stage video { width: 100%; height: 100%; object-fit: contain; display: block; }

.player-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px var(--pad);
  background: var(--surface);
}
.player-bar-title { font-size: var(--fs-small); color: var(--muted); margin: 0; flex: 1; }

/* ------------------------------------------------------------- ad gate */

.adgate {
  position: absolute;
  inset: 0;
  background: #0d0d0d;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
}

.adgate-box { max-width: 320px; }

.adgate-count {
  font-size: 30px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.adgate-text { color: var(--muted); font-size: var(--fs-small); margin: 0 0 16px; }

.adgate-steps { display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
.adgate-step { width: 26px; height: 3px; border-radius: 2px; background: var(--raised-2); }
.adgate-step-on { background: var(--accent); }

.adgate-foot { margin-top: 14px; }

/* ------------------------------------------------------------- billing */

.plan {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plan-featured { background: var(--raised); }

.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.plan-name { font-size: var(--fs-section); font-weight: 600; margin: 0; }
.plan-price { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
.plan-per { color: var(--faint); font-size: 11px; font-weight: 400; }
.plan-desc { color: var(--muted); font-size: var(--fs-small); margin: 0; }

.plan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.plan-list li { display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: var(--fs-small); }
.plan-tick { color: var(--accent); flex: none; margin-top: 1px; }

.entitlement {
  background: var(--raised);
  border-radius: var(--radius-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.entitlement-name { font-size: var(--fs-section); font-weight: 600; margin: 0; }
.entitlement-meta { color: var(--muted); font-size: var(--fs-small); margin: 0; }

/* checkout */

.checkout { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.qr-frame {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  width: 248px;
  height: 248px;
  display: grid;
  place-items: center;
}
.qr-frame img, .qr-frame canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }

.order-no { font-size: var(--fs-small); color: var(--muted); margin: 0; }
.order-amount { font-size: 24px; font-weight: 600; margin: 0; letter-spacing: -0.02em; }

/* The figure the payer must type into their banking app. */
.enter-amount {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 14px 18px;
  text-align: center;
}
.enter-amount .panel-note { margin: 0 0 6px; }
.enter-amount-value {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
}
.status-row + .status-row { border-top: 1px solid var(--rule); }
.status-key { color: var(--muted); font-size: var(--fs-small); }
.status-value { font-size: var(--fs-small); font-weight: 500; text-align: right; }

/* Links to the policy pages, shown on the profile screen. */
.legal-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
}
.pill-active { background: var(--accent-dim); color: var(--accent); }
.pill-pending { background: var(--raised-2); color: var(--muted); }
.pill-expired { background: var(--raised-2); color: var(--faint); }

/* ---------------------------------------------------------------- rows */

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}
.row + .row { border-top: 1px solid var(--rule); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: var(--fs-body); font-weight: 500; margin: 0 0 2px; }
.row-sub { font-size: var(--fs-small); color: var(--faint); margin: 0; }
.row-value { font-size: var(--fs-small); font-weight: 500; white-space: nowrap; }

/* --------------------------------------------------------------- misc */

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--faint);
  font-size: var(--fs-body);
}

.skeleton {
  background: var(--raised);
  border-radius: var(--radius-poster);
  aspect-ratio: 2 / 3;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--raised-2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--raised-2);
  color: var(--text);
  border-radius: var(--radius-control);
  padding: 11px 18px;
  font-size: var(--fs-small);
  z-index: 60;
  max-width: calc(100vw - 32px);
  text-align: center;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fade-up 0.32s cubic-bezier(0.22, 1, 0.36, 1) both; }

@media (prefers-reduced-motion: reduce) {
  .fade-up { animation: none; }
  .spinner { animation-duration: 2s; }
}

/* --------------------------------------------------------- wide screens */

@media (min-width: 900px) {
  .page { max-width: 1080px; margin: 0 auto; }
  .topbar { max-width: 1080px; margin: 0 auto; width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .hero-art { aspect-ratio: 21 / 9; }
  .hero-body { max-width: 1080px; margin: -84px auto 0; }
  .app { padding-bottom: 0; }

  /* On a wide screen the destinations move to a rail on the left, so nothing
     floats over the content. */
  .app {
    display: grid;
    grid-template-columns: 208px 1fr;
    grid-template-rows: auto 1fr;
    column-gap: 28px;
    max-width: 1316px;
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
  }
  .topbar { grid-column: 2; grid-row: 1; padding-left: 0; }
  .page { grid-column: 2; grid-row: 2; padding-bottom: 40px; }

  .tabbar {
    position: sticky;
    top: 0;
    align-self: start;
    grid-column: 1;
    grid-row: 1 / span 2;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    padding: calc(20px + var(--safe-top)) 0 20px;
    border-radius: 0;
  }
  .tab {
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: var(--fs-body);
    color: var(--muted);
  }
  .tab:hover { background: var(--surface); color: var(--text); }
  .tab-on { color: var(--text); background: var(--surface); }
  .tab-dot { display: none; }
  .tab-on .tab-dot { display: none; }
  .tab svg { flex: none; }

  .billing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); align-items: start; }
  .detail-layout { display: grid; grid-template-columns: 260px 1fr; gap: 28px; align-items: start; }
  .detail-layout .detail-art { aspect-ratio: 2 / 3; border-radius: var(--radius-poster); margin: 0; }
  .detail-layout .detail-body { margin: 0; padding: 0; }
  .detail-layout .detail-art::after { display: none; }
}
