/* ==========================================================================
   asatoucan portfolio — main.css
   Dark tabletop, card-red accent (sampled from the TCG key art #d9523d, teal
   #4e9eb8). Bespoke animation exists ONLY in the counter (duel) moment and
   the result beat; everything else is presentation.
   ========================================================================== */

:root {
  --bg: #0d0a12;
  --bg-2: #14141f;
  --panel: rgba(16, 12, 22, 0.94);
  --ink: #f5ead0;
  --ink-dim: #b9a98a;
  --accent: #d9523d;
  --accent-ink: #fff4ef;
  --accent-2: #4e9eb8;
  --focus: #7de3ff;
  --border: rgba(217, 82, 61, 0.5);
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --card-w: clamp(88px, 17vw, 136px);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* canvas + scrollbars stay on-theme — no white flash past the content */
html { background: #0d0a12; color-scheme: dark; }

body {
  background:
    radial-gradient(120vmax 90vmax at 50% 118%, rgba(217, 82, 61, 0.08), transparent 55%),
    radial-gradient(140vmax 100vmax at 50% -30%, #1c1826 0%, var(--bg) 58%);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100dvh;
}

img, svg, video { max-width: 100%; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ------------------------------------- app-mode gating (work pages) ------ */

.page-work #app { display: none; }
html.app-mode #app { display: block; }
html.app-mode .raw-page { display: none; }

/* ------------------------------------------------------------ scene ------ */

.scene-root {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}

/* stage backdrop: dim + blur the tabletop so the work owns the focus.
   Brand + language switcher stay above it (crisp, still usable). */
.scene-root::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(13, 10, 18, 0.6);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.scene-root[data-state="stage"]::after { opacity: 1; }

.wordmark {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 20px;
  z-index: 5;
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  user-select: none;
  writing-mode: vertical-rl;
}

.scene {
  position: absolute;
  inset: 0;
}

/* opponent across the table — floats subtly; click opens the works index */
.opponent-slot {
  position: absolute;
  top: calc(2.5dvh + 34px); /* clear of the wordmark / language row */
  left: 50%;
  transform: translateX(-50%);
  width: min(30vmin, 250px);
}

.opponent-link { display: block; border-radius: 50%; }

.opponent-link:hover .opponent-art,
.opponent-link:focus-visible .opponent-art {
  filter: drop-shadow(0 0 14px rgba(217, 82, 61, 0.85));
}
.opponent-link:focus-visible { outline: none; } /* glow above is the indicator */

.opponent-art {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0.95;
  animation: opponent-float 6s ease-in-out infinite;
}
@keyframes opponent-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* ------------------------------------------------------------- deck ------ */

.region-deck {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); /* pinned to bottom */
  transform: translateX(-50%);
  width: min(94vw, 860px);
  text-align: center;
  z-index: 3;
}

.deck-hint {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: clamp(16px, 2.4vmin, 21px);
  color: var(--ink);
}

.deck {
  list-style: none;
  margin: 0 auto;
  padding: 6px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(8px, 1.6vw, 16px);
}

.card-btn {
  display: block;
  width: var(--card-w);
  aspect-ratio: 5 / 7;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg-2);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.card-btn img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: cover;
}

/* hover-to-play: cards with animated art sit on their still until intent */
.card-btn .card-anim { display: none; }
.card-btn.card-playing .card-still { display: none; }
.card-btn.card-playing .card-anim { display: block; }
.card-btn:hover,
.card-btn:focus-visible {
  transform: translateY(-10px) rotate(-1deg);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55), 0 0 0 2px var(--accent);
}

/* ------------------------------------------------------- counter card ---- */

.region-duel {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none; /* skip button re-enables */
}

.counter-card {
  width: clamp(170px, 34vmin, 260px);
  aspect-ratio: 5 / 7;
  border: 2px solid var(--accent);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-2);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.counter-card img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* budgeted animation #1: the counter */
.counter-card.anim-full { animation: counter-fly 1250ms cubic-bezier(0.2, 0.7, 0.3, 1) both; }
.counter-card.anim-short { animation: counter-slam 480ms cubic-bezier(0.2, 0.7, 0.3, 1) both; }
.region-duel.anim-shake { animation: slam-shake 260ms ease-out 1; }

@keyframes counter-fly {
  0%   { transform: translate(-46vw, -34dvh) rotate(-28deg) scale(0.35); opacity: 0; }
  45%  { opacity: 1; }
  78%  { transform: translate(0, 0) rotate(2deg) scale(1.05); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}
@keyframes counter-slam {
  0%   { transform: scale(1.14) rotate(-2deg); opacity: 0; }
  35%  { opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes slam-shake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(3px, -2px); }
  50% { transform: translate(-3px, 2px); }
  75% { transform: translate(2px, 1px); }
  100% { transform: translate(0, 0); }
}

.skip-btn {
  pointer-events: auto;
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 18px;
  min-height: 44px;
  padding: 8px 18px;
  font: 600 14px var(--sans);
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.skip-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------- stage ----- */

.region-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(94vw, 1100px);
  max-height: 86dvh;
  z-index: 3;
  display: grid;
  place-items: center;
}

.stage-frame {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
}

.stage-frame video,
.stage-frame img {
  display: block;
  width: 100%;
  max-height: 74dvh;
  object-fit: contain;
  background: #000;
  border: 2px solid var(--border);
  border-radius: var(--radius);
}

/* Ken Burns — image stage only, disabled under reduced motion */
.stage-frame img.kenburns { animation: kenburns 36s ease-in-out infinite alternate; }
@keyframes kenburns {
  from { transform: scale(1) translate(0, 0); }
  to   { transform: scale(1.07) translate(-1.4%, 1%); }
}

/* circular corner controls (unmute / close) — 48px hit, never hover-only */
.stage-ctl {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  z-index: 4;
}
.stage-ctl:hover { background: var(--accent); color: var(--accent-ink); }
.stage-ctl svg { width: 22px; height: 22px; }

.stage-ctl[data-unmute] { right: auto; left: 10px; }

/* quality selector (hls.js path only — Safari's native HLS uses its own ABR);
   bottom-left keeps it clear of the unmute button + note up top */
.quality-ctl {
  position: absolute;
  bottom: 64px;
  left: 10px;
  display: flex;
  gap: 6px;
  z-index: 4;
}
.quality-ctl[hidden] { display: none; }
.quality-ctl button {
  padding: 9px 11px;
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.quality-ctl button:hover { border-color: var(--accent); color: var(--accent); }
.quality-ctl button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.unmute-note {
  position: absolute;
  top: 16px;
  left: 66px;
  margin: 0;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--accent);
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  z-index: 4;
  pointer-events: none;
}

.stage-error {
  max-width: 46ch;
  padding: 22px 26px;
  text-align: center;
  background: var(--panel);
  border: 2px solid var(--accent-2);
  border-radius: var(--radius);
}

/* ----------------------------------------------------------- dialogue ---- */
/* One line, name inline, attached below the opponent — a speech bubble. */

.dialogue {
  position: absolute;
  top: calc(2.5dvh + min(30vmin, 250px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(92vw, 560px);
  z-index: 8;
}

.dialogue-line {
  position: relative;
  margin: 0;
  padding: 9px 18px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 15px;
  color: var(--ink);
  text-align: center;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

.dialogue-line::before { /* speech tail pointing at the character */
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--panel);
  border-left: 1.5px solid var(--border);
  border-top: 1.5px solid var(--border);
  border-top-left-radius: 2px;
}

/* language switcher: one segmented pill — EN left, 日本語 right, active side
   lit. Top-right, inline with the wordmark row. */
.lang-ctl {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 20px;
  display: flex;
  padding: 3px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  z-index: 9;
}
.lang-ctl button {
  padding: 7px 13px;
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.lang-ctl button:hover { color: var(--accent); }
.lang-ctl button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

/* creative partnership (works index) — same heading language as "Works" */
.partners { margin: 56px 0; }
.partners-title { margin: 0 0 22px; }
.partners-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ------------------------------------------------------------ result ----- */

.region-result {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 3, 8, 0.6);
}

.result-card {
  width: min(92vw, 560px);
  max-height: 88dvh;
  overflow: auto;
  padding: 30px 32px 26px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
  text-align: center;
}

/* budgeted animation #2: the result beat */
.result-card.anim-in { animation: result-in 520ms cubic-bezier(0.2, 0.7, 0.3, 1) both; }
@keyframes result-in {
  from { transform: translateY(26px) scale(0.94); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.result-stamp {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 999px;
}

.result-title {
  margin: 6px 0 2px;
  font-family: var(--serif);
  font-size: clamp(24px, 4.4vmin, 34px);
}

.result-meta { margin: 0 0 14px; color: var(--ink-dim); font-size: 14px; }
.result-desc { margin: 0 auto 24px; max-width: 44ch; color: var(--ink); }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 22px;
  font: 600 15px var(--sans);
  letter-spacing: 0.02em;
  text-decoration: none;
  border-radius: 999px;
  border: 2px solid var(--border);
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: #e4674f; color: var(--accent-ink); }

/* --------------------------------------------------------- raw pages ----- */

.raw-page {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 22px 80px;
}

.raw-kicker a { color: var(--ink-dim); text-decoration: none; }
.raw-kicker a:hover { color: var(--accent); }
.raw-kicker { font-size: 14px; margin: 0 0 26px; }

.raw-title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: clamp(30px, 6vw, 48px);
  line-height: 1.15;
}

.raw-meta { margin: 0 0 26px; color: var(--ink-dim); letter-spacing: 0.04em; }

.raw-media video,
.raw-media img {
  display: block;
  width: 100%;
  max-height: 76dvh;
  object-fit: contain;
  background: #000;
  border: 2px solid var(--border);
  border-radius: var(--radius);
}

.raw-desc { max-width: 62ch; margin: 24px 0 34px; font-size: 17px; }

.raw-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid rgba(217, 82, 61, 0.25);
  padding-top: 24px;
}
/* one chip component shared by footer contact/socials + partnership list */
.raw-cta {
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}
.raw-cta:hover { border-color: var(--accent); color: var(--accent); }
.raw-cta-quiet { border-color: rgba(217, 82, 61, 0.25); color: var(--ink-dim); }

/* plain works index (/works/) */
.works-index { list-style: none; margin: 0; padding: 0; }
.works-item { padding: 20px 0; border-bottom: 1px solid rgba(217, 82, 61, 0.18); }
.works-item:last-child { border-bottom: 0; }
.works-link {
  font-family: var(--serif);
  font-size: 24px;
  color: var(--accent);
  text-decoration: none;
}
.works-link:hover { text-decoration: underline; }
.works-meta { margin-left: 12px; color: var(--ink-dim); font-size: 14px; }
.works-desc { margin: 6px 0 0; max-width: 62ch; }

/* --------------------------------------------------------- noscript ------ */

.noscript-fallback {
  position: fixed;
  inset: 0;
  z-index: 99;
  padding: 48px 24px;
  background: var(--bg);
  max-width: 640px;
  margin: 0 auto;
}
.noscript-fallback h1 { font-family: var(--serif); }
.noscript-fallback ul { list-style: none; padding: 0; }
.noscript-fallback li { margin: 14px 0; }
.noscript-fallback a { color: var(--accent); font-size: 18px; }
.noscript-meta { color: var(--ink-dim); font-size: 14px; margin-left: 8px; }

/* ------------------------------------------------------------ mobile ----- */

@media (max-width: 720px) {
  .wordmark-sub { display: none; } /* small screens: just "asatoucan" */
  .opponent-slot { width: min(38vmin, 170px); top: calc(1.5dvh + 34px); opacity: 0.9; }
  .dialogue { top: calc(1.5dvh + 34px + min(38vmin, 170px) + 8px); max-width: none; width: min(94vw, 480px); }
  .dialogue-line { font-size: 14px; padding: 8px 14px; box-sizing: border-box; width: 100%; text-align: center; }
  .region-stage { width: 96vw; max-height: 74dvh; }
  .stage-frame video, .stage-frame img { max-height: 62dvh; }
  .stage-ctl { width: 44px; height: 44px; }
  .unmute-note { left: 60px; top: 14px; }
  .result-card { padding: 24px 18px 20px; }

  /* deck: one row, swipe sideways; scrollbar hidden on purpose — the cards
     peeking at BOTH edges (deck.js centers the strip on render) are the
     affordance. No scroll-snap: it would fight the centered start. */
  .deck {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 6px 20px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .deck::-webkit-scrollbar { display: none; }
  .deck li:first-child { margin-left: auto; }
  .deck li:last-child { margin-right: auto; }
}

/* ------------------------------------------------- reduced motion -------- */
/* Kill every animation/transition; content stays fully reachable. JS uses
   the same media query to shorten state timings. */

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