:root {
  color-scheme: dark;
  --bg: #10110e;
  --panel: rgba(255, 255, 255, 0.09);
  --panel-strong: rgba(255, 255, 255, 0.16);
  --text: #fffaf0;
  --muted: rgba(255, 250, 240, 0.72);
  --soft: rgba(255, 250, 240, 0.52);
  --line: rgba(255, 255, 255, 0.2);
  --green: #85d7a0;
  --teal: #59c7c1;
  --amber: #f1b868;
  --coral: #e36f58;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
  --radius: 8px;
  font-family: "Noto Sans Thai", "Sarabun", "Tahoma", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 18%, rgba(227, 111, 88, 0.28), transparent 31rem),
    radial-gradient(circle at 88% 20%, rgba(89, 199, 193, 0.24), transparent 28rem),
    linear-gradient(135deg, #10110e 0%, #15180f 43%, #0b1513 100%);
  overflow-x: hidden;
}

body.is-viewing {
  overflow: hidden;
}

a,
button {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.landing {
  position: relative;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: center;
  gap: clamp(1.4rem, 3vw, 2.6rem);
  padding: clamp(1.1rem, 4vw, 4.5rem);
  isolation: isolate;
}

.landing::before {
  position: absolute;
  inset: 0;
  z-index: -3;
  content: "";
  background:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: linear-gradient(to bottom, transparent, #000 20%, #000 76%, transparent);
}

.ambient {
  position: absolute;
  z-index: -2;
  width: 22rem;
  height: 22rem;
  border-radius: 999px;
  filter: blur(78px);
  opacity: 0.42;
  pointer-events: none;
}

.ambient-one {
  right: 6vw;
  top: 5vh;
  background: var(--teal);
}

.ambient-two {
  bottom: 8vh;
  left: 8vw;
  background: var(--coral);
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(18rem, 0.55fr);
  gap: 1.4rem;
  align-items: end;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 100%;
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0.45rem 0.85rem 0.45rem 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(16px);
}

.brand-lockup img {
  width: clamp(2.8rem, 6vw, 4.15rem);
  height: clamp(2.8rem, 6vw, 4.15rem);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  object-fit: contain;
  padding: 0.18rem;
}

.brand-lockup span {
  display: grid;
  gap: 0.05rem;
  min-width: 0;
}

.brand-lockup strong {
  overflow: hidden;
  color: var(--text);
  font-size: clamp(0.92rem, 1.7vw, 1.05rem);
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-lockup small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kicker,
.viewer-title-block p {
  margin: 0 0 0.45rem;
  color: var(--amber);
  font-size: clamp(0.75rem, 1.4vw, 0.9rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 6.5rem);
  line-height: 0.98;
  letter-spacing: 0;
  text-wrap: balance;
}

.masthead-copy {
  max-width: 32rem;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.18rem);
  line-height: 1.75;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.9rem, 2.2vw, 1.35rem);
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  perspective: 1200px;
}

.credit-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.85rem, 2vw, 1.2rem);
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: var(--radius);
  padding: clamp(0.95rem, 2.4vw, 1.35rem);
  color: var(--muted);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.05));
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.24);
  text-align: center;
  backdrop-filter: blur(18px);
}

.credit-footer img {
  width: clamp(4.6rem, 8vw, 6.7rem);
  height: clamp(4.6rem, 8vw, 6.7rem);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  object-fit: contain;
  padding: 0.25rem;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
}

.credit-footer div {
  display: grid;
  gap: 0.18rem;
}

.credit-footer p {
  margin: 0 0 0.1rem;
  color: var(--amber);
  font-size: 0.86rem;
  font-weight: 900;
}

.credit-footer strong {
  color: var(--text);
  font-size: clamp(1.32rem, 3vw, 2.35rem);
  font-weight: 900;
  line-height: 1.18;
}

.credit-footer span {
  color: rgba(255, 250, 240, 0.78);
  font-size: clamp(0.92rem, 1.7vw, 1.18rem);
  font-weight: 800;
  line-height: 1.25;
}

.movie-card {
  min-width: 0;
  opacity: 0;
  transform: translateY(26px);
  animation: cardIn 0.82s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.movie-card:nth-child(2) {
  animation-delay: 0.12s;
}

.movie-card:nth-child(3) {
  animation-delay: 0.24s;
}

.card-link {
  position: relative;
  display: block;
  min-height: clamp(25rem, 49vw, 39rem);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  background: #161a15;
  box-shadow: var(--shadow);
  transform-style: preserve-3d;
  transition:
    transform 360ms ease,
    border-color 360ms ease,
    box-shadow 360ms ease,
    filter 360ms ease;
}

.card-link:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 5px;
}

.card-link:hover {
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.62);
  filter: saturate(1.08);
  transform: translateY(-10px) rotateX(3deg);
}

.card-link img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.03);
  transition: transform 700ms ease;
}

.card-link:hover img {
  transform: scale(1.1);
}

.card-link::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.42) 38%, transparent 70%),
    linear-gradient(135deg, rgba(0, 0, 0, 0.34), transparent 46%);
}

.card-shine {
  position: absolute;
  inset: -40% auto auto -70%;
  z-index: 2;
  width: 42%;
  height: 190%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transform: rotate(18deg);
  transition: left 650ms ease;
}

.card-link:hover .card-shine {
  left: 122%;
}

.card-content {
  position: absolute;
  inset: auto 0 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: clamp(1rem, 2.6vw, 1.5rem);
}

.episode {
  width: fit-content;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 999px;
  padding: 0.2rem 0.55rem 0.16rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.8rem;
  font-weight: 900;
}

.card-title {
  display: block;
  font-size: clamp(1.45rem, 2.8vw, 2.35rem);
  font-weight: 900;
  line-height: 1.12;
  text-wrap: balance;
}

.card-desc {
  display: block;
  min-height: 3.2em;
  color: var(--muted);
  font-size: clamp(0.92rem, 1.45vw, 1.05rem);
  line-height: 1.6;
}

.card-action,
.source-link,
.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  width: fit-content;
  min-height: 2.6rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0.58rem 0.86rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px);
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
}

svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
  flex: 0 0 auto;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  background: #0d0f0b;
}

.viewer[hidden] {
  display: none;
}

.viewer-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(180deg, rgba(0, 0, 0, 0.74), rgba(0, 0, 0, 0.9)),
    var(--viewer-image);
  background-position: center;
  background-size: cover;
  filter: blur(18px) saturate(0.9);
  transform: scale(1.06);
}

.viewer-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem clamp(0.8rem, 2vw, 1.4rem);
  border-bottom: 1px solid var(--line);
  background: rgba(14, 15, 12, 0.78);
  backdrop-filter: blur(20px);
}

.viewer-title-block {
  min-width: 0;
}

.viewer-title-block p {
  margin-bottom: 0.15rem;
  font-size: 0.72rem;
}

.viewer-title-block h2 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back-button {
  cursor: pointer;
}

.back-button:hover,
.source-link:hover {
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.17);
}

.frame-shell {
  position: relative;
  margin: clamp(0.55rem, 1.5vw, 1rem);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: var(--shadow);
}

iframe {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.9rem;
  color: var(--text);
  background:
    radial-gradient(circle at center, rgba(133, 215, 160, 0.16), transparent 21rem),
    rgba(12, 13, 10, 0.82);
}

.loader span {
  width: 3rem;
  height: 3rem;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--amber);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.loader strong {
  font-size: 1rem;
}

.loader.is-done {
  pointer-events: none;
  opacity: 0;
  transition: opacity 260ms ease;
}

.frame-note {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 3;
  max-width: min(34rem, calc(100% - 2rem));
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  padding: 0.72rem 0.85rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.7);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  font-size: 0.9rem;
  line-height: 1.55;
}

@keyframes cardIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .landing {
    justify-content: flex-start;
    padding-top: 2rem;
  }

  .masthead {
    grid-template-columns: 1fr;
  }

  .gallery {
    grid-template-columns: 1fr;
  }

  .card-link {
    min-height: clamp(20rem, 72vw, 28rem);
  }

  .card-desc {
    min-height: auto;
  }

  .credit-footer {
    align-items: center;
  }
}

@media (max-width: 720px) {
  body.is-viewing {
    overflow: auto;
  }

  .landing {
    min-height: auto;
    padding: 1rem;
  }

  h1 {
    font-size: clamp(2.15rem, 13vw, 4rem);
  }

  .masthead-copy {
    font-size: 0.98rem;
  }

  .brand-lockup {
    width: 100%;
    border-radius: var(--radius);
  }

  .brand-lockup strong {
    white-space: normal;
  }

  .credit-footer {
    flex-direction: column;
  }

  .viewer {
    position: fixed;
  }

  .viewer-bar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title title"
      "back source";
    gap: 0.65rem;
  }

  .viewer-title-block {
    grid-area: title;
  }

  .back-button {
    grid-area: back;
  }

  .source-link {
    grid-area: source;
  }

  .back-button,
  .source-link {
    width: 100%;
    min-height: 2.45rem;
    padding-inline: 0.7rem;
    font-size: 0.86rem;
  }

  .frame-shell {
    margin: 0.55rem;
  }
}

@media (max-width: 430px) {
  .card-link {
    min-height: 26rem;
  }

  .card-content {
    padding: 1rem;
  }

  .card-title {
    font-size: 1.55rem;
  }

  .card-action {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
