/* ============================================================================
   git-tok
   A warm, printed-page feel: cream stock, ink type, and a single wash of
   colour per card borrowed from the repository's language.
   ========================================================================= */

:root {
  --paper:      #fbf7f0;
  --paper-2:    #f4ece0;
  --card:       #fffdf9;
  --ink:        #191510;
  --ink-2:      #443c33;
  --muted:      #857a6c;
  --line:       rgba(25, 21, 16, 0.14);
  --line-soft:  rgba(25, 21, 16, 0.07);
  --accent:     #b4441f;
  --lang:       #8a7f70;

  --shadow-sm: 0 1px 2px rgba(60, 45, 25, 0.06), 0 2px 8px rgba(60, 45, 25, 0.05);
  --shadow-md: 0 2px 6px rgba(60, 45, 25, 0.07), 0 18px 44px -18px rgba(60, 45, 25, 0.28);

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --topbar-h: 66px;
  --hud-h: 54px;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Faint paper grain over the whole app. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}

a { color: inherit; }

.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;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 3vw, 34px);
  background: linear-gradient(to bottom, rgba(251, 247, 240, 0.94), rgba(251, 247, 240, 0.72) 60%, rgba(251, 247, 240, 0));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 11px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-sm);
}
.brand__mark svg { width: 20px; height: 20px; }

.brand__word {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 600;
}
.brand__tok {
  color: var(--accent);
  font-style: italic;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 34px 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.select::after {
  content: "";
  position: absolute;
  right: 14px;
  width: 7px; height: 7px;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
}
.select__label {
  font-size: 0.7rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 8px;
}
.select select {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--ink);
  cursor: pointer;
  outline: none;
  max-width: 130px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(25, 21, 16, 0.24);
  box-shadow: 0 3px 10px rgba(60, 45, 25, 0.1);
}
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.btn--primary:hover { background: #0f0c08; }

.topbar .btn { height: 38px; }

.ico { width: 17px; height: 17px; flex: none; }

/* ---------------------------------------------------------------- the feed */

.feed {
  height: 100svh;
  overflow-y: scroll;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  outline: none;
  overscroll-behavior-y: contain;
}
.feed::-webkit-scrollbar { width: 0; height: 0; }

.card {
  position: relative;
  height: 100svh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: grid;
  place-items: center;
  padding: calc(var(--topbar-h) + 10px) clamp(18px, 4vw, 54px) calc(var(--hud-h) + 10px);
  overflow: hidden;
}

/* The colour wash — a soft bloom of the repo's language colour. */
.card__wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 85% at 78% 12%, color-mix(in oklab, var(--lang) 26%, transparent), transparent 62%),
    radial-gradient(95% 70% at 8% 96%, color-mix(in oklab, var(--lang) 16%, transparent), transparent 60%),
    linear-gradient(168deg, var(--paper), var(--paper-2));
}
.card__wash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(251, 247, 240, 0.55), transparent 22%, transparent 78%, rgba(251, 247, 240, 0.55));
}

.card__grid {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: center;
  gap: clamp(28px, 5vw, 64px);
}
.card__grid--single { grid-template-columns: minmax(0, 1fr); max-width: 720px; }
.card--no-media .card__grid { grid-template-columns: minmax(0, 1fr); max-width: 760px; margin-inline: auto; }
.card--no-media .card__media { display: none; }

/* ------------------------------------------------------------- card: text */

.card__body { min-width: 0; }

/* Everything lifts in gently as the card snaps into view. */
.card__body > *,
.card__media > * {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.card.is-live .card__body > *,
.card.is-live .card__media > * {
  opacity: 1;
  transform: none;
}
.card.is-live .card__body > *:nth-child(2) { transition-delay: 0.04s; }
.card.is-live .card__body > *:nth-child(3) { transition-delay: 0.08s; }
.card.is-live .card__body > *:nth-child(4) { transition-delay: 0.12s; }
.card.is-live .card__body > *:nth-child(5) { transition-delay: 0.16s; }
.card.is-live .card__body > *:nth-child(6) { transition-delay: 0.19s; }
.card.is-live .card__body > *:nth-child(7) { transition-delay: 0.22s; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow__num { color: color-mix(in oklab, var(--lang) 72%, var(--ink)); font-weight: 700; }
.eyebrow__sep { width: 26px; height: 1px; background: var(--line); }

.owner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 5px 14px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.72);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 550;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.owner:hover { border-color: rgba(25, 21, 16, 0.26); background: var(--card); }
.owner__avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--paper-2);
  object-fit: cover;
}
.owner__avatar--blank {
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--lang) 22%, var(--paper-2));
  color: color-mix(in oklab, var(--lang) 55%, var(--ink));
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
}

.title {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.7rem, 6.4vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}
.title a {
  text-decoration: none;
  background-image: linear-gradient(color-mix(in oklab, var(--lang) 60%, var(--ink)), color-mix(in oklab, var(--lang) 60%, var(--ink)));
  background-size: 0% 2px;
  background-repeat: no-repeat;
  background-position: 0 92%;
  transition: background-size 0.3s ease;
}
.title a:hover { background-size: 100% 2px; }

.desc {
  margin: 0 0 20px;
  max-width: 46ch;
  font-size: clamp(1.02rem, 1.35vw, 1.2rem);
  line-height: 1.55;
  color: var(--ink-2);
}
.desc em { color: var(--muted); }

.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}
.topic {
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--lang) 28%, var(--line));
  background: color-mix(in oklab, var(--lang) 9%, var(--card));
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.01em;
  color: color-mix(in oklab, var(--lang) 45%, var(--ink-2));
}

.facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-bottom: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.83rem;
  color: var(--muted);
}
.fact { display: inline-flex; align-items: center; gap: 7px; }
.fact .ico { width: 15px; height: 15px; opacity: 0.75; }
.fact--warn { color: #9a5b1c; }
.swatch {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--lang);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--lang) 18%, transparent);
}

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

/* ------------------------------------------------------------ card: media */

.card__media {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 26px);
  min-width: 0;
}

.preview {
  flex: 1;
  min-width: 0;
  display: block;
  border-radius: 18px;
  overflow: hidden;
  background: color-mix(in oklab, var(--lang) 10%, var(--card));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  transform: rotate(-1.1deg);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease;
}
.preview:hover { transform: rotate(0deg) scale(1.015); }
.preview__img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.card--media-ready .preview__img { opacity: 1; }

/* TikTok-style vertical stat rail. */
.rail {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: none;
}
.rail__item {
  display: grid;
  justify-items: center;
  gap: 2px;
}
.rail__dial {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: color-mix(in oklab, var(--lang) 55%, var(--ink));
}
.ico--rail { width: 21px; height: 21px; }
.rail__value {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.rail__label {
  font-size: 0.63rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ------------------------------------------------------------------- HUD */

.hud {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  height: var(--hud-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 3vw, 34px);
  pointer-events: none;
  background: linear-gradient(to top, rgba(251, 247, 240, 0.92), rgba(251, 247, 240, 0));
}

.hud__counter {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  order: 2;
}

.hud__status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 0.8rem;
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  order: 1;
}
.hud__status.is-on { opacity: 1; transform: none; }
.hud__status.is-on::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50%      { opacity: 1;    transform: scale(1); }
}

/* ------------------------------------------------------- hint, toast, boot */

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(var(--hud-h) + 6px);
  z-index: 41;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.9);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-sm);
  font-size: 0.8rem;
  color: var(--ink-2);
  transform: translateX(-50%);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}
.hint svg { width: 15px; height: 15px; animation: nudge 1.8s ease-in-out infinite; }
.hint.is-gone { opacity: 0; transform: translate(-50%, 10px); }

@keyframes nudge {
  0%, 100% { transform: translateY(-2px); }
  50%      { transform: translateY(3px); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--hud-h) + 18px);
  z-index: 55;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.85rem;
  font-weight: 550;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: linear-gradient(168deg, var(--paper), var(--paper-2));
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.boot.is-gone { opacity: 0; visibility: hidden; }
.boot__inner { text-align: center; }
.boot__reel {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
}
.boot__reel i {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--ink);
  animation: reel 1.1s ease-in-out infinite;
}
.boot__reel i:nth-child(2) { animation-delay: 0.15s; background: var(--accent); }
.boot__reel i:nth-child(3) { animation-delay: 0.3s; }

@keyframes reel {
  0%, 100% { transform: translateY(0);     opacity: 0.35; }
  40%      { transform: translateY(-11px); opacity: 1; }
}

.boot__title {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}
.boot__sub { margin: 0; font-size: 0.88rem; color: var(--muted); }

/* --------------------------------------------------------------- responsive */

@media (max-width: 1000px) {
  .card__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    align-content: center;
  }
  .card__media { flex-direction: column-reverse; align-items: stretch; gap: 16px; }
  .preview { transform: none; }
  .preview:hover { transform: scale(1.01); }
  .rail { flex-direction: row; justify-content: flex-start; gap: 26px; }
  .title { font-size: clamp(2.4rem, 9vw, 3.4rem); }
  .desc { max-width: none; font-size: 1rem; }
}

@media (max-width: 620px) {
  :root { --topbar-h: 58px; }
  .brand__word { font-size: 1.2rem; }
  .select__label { display: none; }
  .select { padding-left: 14px; }
  .topbar .btn span { display: none; }
  .topbar .btn { padding: 0 12px; }
  .facts { gap: 6px 14px; font-size: 0.78rem; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .rail__dial { width: 40px; height: 40px; }
  .preview__img { aspect-ratio: 16 / 9; }
}

@media (max-height: 620px) {
  .preview { display: none; }
  .title { font-size: clamp(2rem, 6vw, 2.8rem); }
  .facts { margin-bottom: 16px; padding-top: 10px; }
  .topics { margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
  .feed { scroll-behavior: auto; }
  .card__body > *, .card__media > * { opacity: 1; transform: none; transition: none; }
  .preview { transform: none; }
}
