/* ---------- Tokens ---------- */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --fg: #16161a;
  --fg-2: #3b3b44;
  --muted: #6c6c78;
  --line: #e4e4de;
  --accent: #4338ca;
  --accent-fg: #ffffff;
  --accent-soft: #eceafd;
  --highlight: #f59e0b;
  --shadow: 0 1px 2px rgb(16 16 24 / 6%), 0 8px 24px -12px rgb(16 16 24 / 18%);
  --shadow-lg: 0 2px 4px rgb(16 16 24 / 6%), 0 24px 48px -20px rgb(16 16 24 / 30%);
  --radius: 16px;
  --font: "Be Vietnam Pro", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --wrap: 1120px;
  --topbar: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d10;
    --surface: #17171c;
    --surface-2: #1f1f26;
    --fg: #f3f3f5;
    --fg-2: #cfcfd6;
    --muted: #9a9aa6;
    --line: #2a2a32;
    --accent: #a5b4fc;
    --accent-fg: #0d0d10;
    --accent-soft: #1e1b4b;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -12px rgb(0 0 0 / 60%);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / 40%), 0 24px 48px -20px rgb(0 0 0 / 70%);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 16px/1.65 var(--font); -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 24px; }
.wrap-wide { max-width: calc(var(--wrap) + 160px); }
.eyebrow {
  font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; height: var(--topbar);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  height: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 24px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; text-decoration: none; white-space: nowrap; }
.mark { width: 28px; height: 28px; }
.mark rect { fill: var(--accent); }
.mark path { fill: none; stroke: var(--accent-fg); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.mark circle { fill: var(--highlight); }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav > a:not(.btn) {
  font-size: .92rem; font-weight: 500; color: var(--fg-2); text-decoration: none;
  padding: 8px 12px; border-radius: 999px; transition: background .15s, color .15s;
}
.nav > a:not(.btn):hover { background: var(--surface-2); color: var(--fg); }
.icon-link { display: inline-flex; }
.icon-link svg, .btn svg, .back svg, .badge svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.topbar-title {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-size: .92rem; padding-left: 20px; border-left: 1px solid var(--line);
}

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent;
  background: var(--fg); color: var(--bg); font: 600 .9rem/1 var(--font); text-decoration: none; white-space: nowrap;
  transition: transform .15s, opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); opacity: 1; }
.btn-ghost svg path { fill: currentColor; stroke: none; }
.btn-block { width: 100%; height: 44px; }
.btn-block svg path { fill: currentColor; stroke: none; }

.chip {
  height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg-2); font: 500 .88rem/1 var(--font); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--muted); color: var(--fg); }
.chip.is-active { background: var(--fg); border-color: var(--fg); color: var(--bg); }

/* ---------- Home ---------- */
.hero { position: relative; padding-top: clamp(48px, 9vw, 104px); padding-bottom: clamp(36px, 6vw, 64px); }
.hero::before {
  content: ""; position: absolute; z-index: -1; top: 24px; right: 0; width: min(560px, 55%); height: 100%;
  background-image: radial-gradient(color-mix(in srgb, var(--accent) 38%, transparent) 1.2px, transparent 1.6px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(closest-side, #000 20%, transparent);
  mask-image: radial-gradient(closest-side, #000 20%, transparent);
  pointer-events: none;
}
main { isolation: isolate; overflow-x: clip; }
.hero h1 {
  margin-top: 16px; font-size: clamp(2.4rem, 6.2vw, 4.4rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.04;
}
.hero h1 em {
  font-style: normal; color: var(--accent);
  background: linear-gradient(transparent 68%, var(--accent-soft) 68%);
}
.hero .lede { margin-top: 22px; max-width: 58ch; font-size: clamp(1.02rem, 1.6vw, 1.18rem); color: var(--muted); }

.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-head h2 { font-size: 1.35rem; display: flex; align-items: center; gap: 10px; }
.count {
  font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--surface-2);
  padding: 2px 9px; border-radius: 999px; letter-spacing: 0;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 28px; }
.card-featured { margin-bottom: 28px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-link { display: flex; flex-direction: column; height: 100%; text-decoration: none; color: inherit; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; border-bottom: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform .4s ease; }
/* Portrait cover on a 16:9 card: blurred fill behind the full frame. */
.thumb-portrait::before { content: ""; position: absolute; inset: -24px; background: var(--thumb) center / cover; filter: blur(22px) saturate(1.2); opacity: .75; }
.thumb-portrait img { position: relative; object-fit: contain; object-position: center; }
.card:hover .thumb img { transform: scale(1.03); }
.badge {
  position: absolute; left: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px; border-radius: 999px; font-size: .76rem; font-weight: 600; color: #fff;
  background: rgb(14 14 20 / 78%); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.badge svg { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.badge-sep { opacity: .6; }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px 20px; flex: 1; }
.kicker { font-size: .8rem; font-weight: 600; color: var(--accent); }
.card-title { font-size: 1.08rem; font-weight: 700; line-height: 1.35; letter-spacing: -0.01em; }
.card-excerpt {
  color: var(--muted); font-size: .95rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { margin-top: auto; padding-top: 6px; font-size: .8rem; color: var(--muted); }

@media (min-width: 900px) {
  .card-featured .card-link { flex-direction: row; }
  .card-featured .thumb { flex: 0 0 58%; aspect-ratio: 16 / 9; align-self: center; border-bottom: 0; border-right: 1px solid var(--line); }
  .card-featured .card-link { align-items: stretch; }
  .card-featured .thumb img { object-position: center; }
  .card-featured .card-body { padding: clamp(24px, 3vw, 40px); justify-content: center; gap: 12px; }
  .card-featured .card-title { font-size: clamp(1.4rem, 2.2vw, 1.85rem); line-height: 1.22; letter-spacing: -0.02em; }
  .card-featured .card-meta { margin-top: 8px; }
}

/* About */
.about { padding-top: clamp(64px, 9vw, 112px); padding-bottom: clamp(56px, 8vw, 96px); }
.about h2 { font-size: 1.35rem; margin-bottom: 24px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.step-n { font-size: .8rem; font-weight: 700; color: var(--accent); letter-spacing: .06em; }
.steps h3 { font-size: 1.05rem; margin: 10px 0 6px; }
.steps p { color: var(--muted); font-size: .95rem; }

/* ---------- Post ---------- */
.post-head { padding-top: clamp(28px, 5vw, 48px); padding-bottom: 28px; }
.post-head-after { border-top: 1px solid var(--line); }
.back {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 28px;
  font-size: .9rem; font-weight: 500; color: var(--muted); text-decoration: none;
}
.back:hover { color: var(--fg); }
.back svg { width: 16px; height: 16px; }
.post-head h1 { margin-top: 12px; max-width: 26ch; font-size: clamp(1.9rem, 4.4vw, 3rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.12; }
.byline { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: .95rem; }
.byline strong { color: var(--fg); font-weight: 600; }
.dot { opacity: .5; }

.stage {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: #0b0b0e; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.stage iframe, .video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Vertical shorts: a phone-shaped player, as tall as the screen allows. */
.stage-portrait { aspect-ratio: 9 / 16; width: min(100%, calc((100dvh - var(--topbar) - 120px) * 9 / 16)); min-width: min(100%, 300px); margin-inline: auto; }
.stage-note { margin-top: 12px; font-size: .88rem; color: var(--muted); text-align: center; }
.stage-note a { color: var(--fg-2); }

.post-body {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(32px, 5vw, 72px); align-items: start;
  padding-top: clamp(40px, 6vw, 64px);
}
.prose { max-width: 68ch; }
.prose h2 { font-size: 1.35rem; margin-bottom: 18px; }
.prose p { color: var(--fg-2); font-size: 1.04rem; line-height: 1.8; }
.prose p + p { margin-top: 1.1em; }
.prose p:first-of-type { font-size: 1.15rem; color: var(--fg); line-height: 1.7; }
.prose strong { color: var(--fg); font-weight: 700; }
.is-app .post-body { padding-top: 8px; }

.source-card {
  position: sticky; top: calc(var(--topbar) + 24px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.source-name { margin-top: 8px; font-weight: 700; font-size: 1.05rem; line-height: 1.35; }
.source-note { margin: 10px 0 18px; color: var(--muted); font-size: .9rem; }

.original { padding-top: clamp(48px, 7vw, 80px); }
.original h2, .more h2 { font-size: 1.35rem; margin-bottom: 20px; }
.video { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; max-width: 860px; border-radius: var(--radius); overflow: hidden; background: #000; }
.yt-facade { border: 0; padding: 0; cursor: pointer; box-shadow: var(--shadow); }
.yt-facade img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease, filter .3s; }
.yt-facade:hover img { transform: scale(1.02); filter: brightness(.9); }
.yt-play {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 72px; height: 50px; border-radius: 14px;
  display: grid; place-items: center; background: #ff0033; box-shadow: 0 8px 24px rgb(0 0 0 / 30%); transition: transform .2s;
}
.yt-facade:hover .yt-play { transform: scale(1.06); }
.yt-play svg { width: 26px; height: 26px; fill: #fff; }

.more { padding-top: clamp(56px, 8vw, 96px); padding-bottom: clamp(56px, 8vw, 96px); }

/* Interactive pages: full screen under the top bar */
.topbar-app { max-width: none; }
.app-frame { display: block; width: 100%; height: calc(100vh - var(--topbar)); height: calc(100dvh - var(--topbar)); border: 0; background: var(--surface); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 32px 0; color: var(--muted); font-size: .88rem; }
.footer-in { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.footer .brand { color: var(--fg); }
.footer a:not(.brand) { text-decoration: none; font-weight: 500; }
.footer a:not(.brand):hover { color: var(--fg); }
.footer p { flex: 1; min-width: 220px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .post-body { grid-template-columns: minmax(0, 1fr); }
  .source-card { position: static; }
}
@media (max-width: 640px) {
  :root { --topbar: 56px; }
  .wrap, .topbar-in { padding-inline: 16px; }
  .nav > a:not(.btn):not(.icon-link) { display: none; }
  .topbar-title { display: none; }
  .topbar-app .btn { height: 34px; padding: 0 12px; }
  .topbar-app .btn-ghost span { display: none; }
  .brand span { font-size: .95rem; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding-inline: 16px; scrollbar-width: none; width: calc(100% + 32px); }
  .filters::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .stage { border-radius: 12px; }
  .wrap-wide { padding-inline: 0; }
  .wrap-wide .stage { border-radius: 0; border-inline: 0; }
  .wrap-wide .stage-portrait { width: 100%; min-width: 0; }
  .wrap-wide .stage-note { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
