@import url("https://files.mandrock.me/web/mandrock0-tokens.css");
/* watchlog landing. System colors are loaded from the canonical CDN. */
:root {
  color-scheme: dark;
  --radius-card: .25rem;
  --radius-control: 1rem;





  --action: var(--accent-purple);
  --info:   var(--accent-cyan);
  --ok:     var(--accent-lime);
  --alive:  var(--accent-crimson);






  --primary:    var(--accent-purple);





  --ring:       var(--accent-cyan);

  --glow: var(--accent-purple);
  --glow-ambient:   0 0 0 1px color-mix(in oklch, var(--glow) 14%, transparent);
  --glow-attention: 0 0 0 1px color-mix(in oklch, var(--glow) 55%, transparent),
                    0 0 20px color-mix(in oklch, var(--glow) 40%, transparent);

  --glitch-budget: 1;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-reduced-motion: reduce) { :root { --glitch-budget: 0; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--foreground);
  font: 1rem/1.5 var(--font); min-height: 100vh;
}
.wrap { width: min(100% - 2rem, 72rem); margin-inline: auto; }
a { color: var(--accent-cyan); text-underline-offset: .2em; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.vh, .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: .5rem; top: -4rem; background: var(--foreground); color: var(--primary-foreground);
  padding: .6rem 1rem; z-index: 10; }
.skip:focus { top: .5rem; }

/* header + nav */
.top { border-bottom: 1px solid var(--border); background: var(--background); position: sticky; top: 0; z-index: 5; }
.top-in { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; padding-block: .5rem; position: relative; }
.brand { margin: 0; font: 700 1.1rem var(--mono); letter-spacing: .04em; }
.brand-mark { color: var(--accent-purple); }
.nav { margin-left: auto; }
.nav ul { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.nav a { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: 0 .75rem;
  color: var(--foreground); text-decoration: none; border-radius: var(--radius-card); }
.nav a:hover { background: var(--secondary); }
.n { font: 600 .8rem var(--mono); color: var(--muted-foreground); background: var(--muted);
  padding: .05rem .4rem; border-radius: 99px; border: 1px solid var(--border); }

.view-switch { margin-left: auto; display: flex; gap: .25rem; }
.view-switch + .nav { margin-left: 0; }
.view-switch a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .75rem; color: var(--foreground);
  text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius-control); }
.view-switch a:hover { background: var(--secondary); }
.view-switch a[aria-current="true"] { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); font-weight: 700; }

/* debris: decorative shards, content lives in ::before (not in a11y tree / copy buffer) */
.debris-bit { --debris-content: "▞▚░▒ 0x7f ▓░▚"; display: inline-block; pointer-events: none; user-select: none;
  font: .7rem/1 var(--mono); color: var(--accent-purple); opacity: .55; }
.debris-bit::before { content: var(--debris-content); }
.debris-strip { --debris-content: "░▒▓█▓▒░ ▞▚ 00 11 ░▒"; position: relative; overflow: hidden;
  width: 7.5rem; height: .9rem; border-block: 1px dashed var(--border); transform: translateY(2px) skewX(-18deg); }
.debris-block { --debris-content: "▚▞▚▞ ▒▒░░ ▞"; position: absolute; right: 1rem; top: .75rem;
  transform: rotate(4deg); color: var(--accent-cyan); opacity: .45; }

/* sections */
main { padding-block: 1.25rem 3rem; }
section { margin-block: 2rem; }
h2 { font: 700 1.25rem/1.2 var(--font); margin: 0 0 .75rem; display: flex; align-items: center; gap: .6rem; }
h2::before { content: ""; width: .6rem; height: 1.1rem; background: var(--accent-purple); transform: skewX(-18deg); }
.lead { color: var(--muted-foreground); margin: 0 0 1rem; max-width: 60ch; }
.flash { margin: 0 0 1rem; padding: .75rem 1rem; border-radius: var(--radius-card); border: 1px solid; }
.flash-ok  { border-color: var(--ok); background: color-mix(in oklch, var(--ok) 10%, var(--card)); }
.flash-err { border-color: var(--destructive); background: color-mix(in oklch, var(--destructive) 12%, var(--card)); }

/* cards: one column everywhere (a11y gate: no side-by-side text), deliberate sloppy offsets */
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: .75rem; max-width: 72ch; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card);
  box-shadow: var(--glow-ambient); padding: .85rem; position: relative; scroll-margin-top: 4rem; min-width: 0; }
.card[data-state="behind"] { border-left: 4px solid var(--accent-crimson); }
.card[data-state="caught_up"] { border-left: 4px solid var(--ok); }
.card[data-state="unknown"] { border-left: 4px dotted var(--muted-foreground); }
.card:target { box-shadow: var(--glow-attention); }
.card-head { display: flow-root; }
.poster { float: right; margin: 0 0 .5rem .85rem; width: 72px; height: 102px; object-fit: cover; border-radius: 2px; background: var(--muted); }
.poster-empty { display: grid; place-items: center; font: 700 1.8rem var(--mono); color: var(--accent-purple);
  border: 1px dashed var(--border); }
.card-info { min-width: 0; flex: 1; }
.card-title { margin: 0 0 .25rem; font-size: 1.05rem; line-height: 1.25; overflow-wrap: anywhere; }

.prog { margin: 0 0 .35rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; }
.prog-ep { font-variant-numeric: tabular-nums; }
.meta { margin: 0 0 .6rem; color: var(--muted-foreground); font-size: .9rem; display: flex; flex-wrap: wrap; gap: .2rem .9rem; }
.tag { border: 1px solid var(--border); padding: 0 .4rem; border-radius: 2px; color: var(--foreground); }
.tag-warn { border-color: var(--destructive); }

/* state badges: glyph + text, never colour alone */
.badge { display: inline-flex; align-items: center; min-height: 1.6rem; padding: 0 .55rem; font: 700 .8rem var(--mono);
  border: 1px solid; border-radius: 2px; position: relative; }
.badge-behind { color: var(--foreground); border-color: var(--accent-crimson); background: color-mix(in oklch, var(--accent-crimson) 28%, var(--card)); }
.badge-ok { color: var(--ok); border-color: var(--ok); }
.badge-unk { color: var(--muted-foreground); border-color: var(--muted-foreground); border-style: dashed; }

/* buttons + forms */
.btn { font: 600 .95rem var(--font); min-height: 44px; padding: 0 1rem; color: var(--foreground); background: var(--secondary);
  border: 1px solid var(--border); border-radius: var(--radius-control); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; text-decoration: none; }
.btn:hover { border-color: var(--accent-purple); }
.btn-primary { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.btn-primary:hover { box-shadow: var(--glow-attention); }
.btn-danger { color: var(--destructive); border-color: var(--destructive); }
.manage { margin-top: .75rem; border-top: 1px solid var(--border); padding-top: .25rem; }
.manage summary, .fold summary { min-height: 44px; display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 600; }
.forms { display: grid; gap: .6rem; padding-block: .5rem; }
.row { display: grid; grid-template-columns: 1fr auto; gap: .3rem .5rem; align-items: end; }
.row label { grid-column: 1 / -1; font-size: .85rem; color: var(--muted-foreground); }
input[type=text], input[type=number], select { width: 100%; min-height: 44px; padding: 0 .7rem; font: inherit;
  color: var(--foreground); background: var(--muted); border: 1px solid var(--input); border-radius: var(--radius-card); }
.fold { margin-block: 1rem; }
.fold details { border: 1px solid var(--border); border-radius: var(--radius-card); padding: 0 .85rem; background: var(--card); }
.fold .cards { padding-bottom: .85rem; }

/* empty state */
.empty { position: relative; background: var(--card); border: 1px dashed var(--border); padding: 1.25rem; border-radius: var(--radius-card); max-width: 44rem; }
.empty h2::before { background: var(--accent-cyan); }
.empty ol { padding-left: 1.2rem; }
.empty code, .hint code { font-family: var(--mono); background: var(--muted); padding: .05rem .35rem; border-radius: 2px; overflow-wrap: anywhere; }
.hint { color: var(--muted-foreground); }
.foot { padding-block: 1.5rem; color: var(--muted-foreground); font-size: .85rem; border-top: 1px solid var(--border); }

@media (min-width: 48rem) {
  .cards { gap: 1rem; }
  .cards > .card:nth-child(3n+2) { margin-top: 1.1rem; transform: translateX(.35rem); }
  .cards > .card:nth-child(3n) { margin-left: -.25rem; }
}

/* motion: everything below only when the user has not asked for reduced motion */
@keyframes debris-pulse { 0%, 100% { opacity: .3; } 50% { opacity: .75; } }
@keyframes debris-glitch {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(calc(var(--glitch-budget) * 2px), 0); }
  50% { transform: translate(calc(var(--glitch-budget) * -2px), calc(var(--glitch-budget) * 1px)); }
}
/* new glitch detail: RGB-split of the "behind" badge text, one 240ms burst on load and on card hover/focus */
@keyframes rgb-split {
  0%, 100% { text-shadow: none; transform: none; }
  30% { text-shadow: 2px 0 var(--accent-cyan), -2px 0 var(--accent-purple); transform: translateX(1px); }
  60% { text-shadow: -2px 0 var(--accent-cyan), 2px 0 var(--accent-purple); transform: translateX(-1px); }
}
@keyframes slice-sweep { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(100% 0 0 0); } }

@media (prefers-reduced-motion: no-preference) {
  .debris-bit[data-alive="true"] { animation: debris-pulse 2.4s ease-in-out infinite; }
  .debris-bit[data-glitch="true"]:hover { animation: debris-glitch 240ms steps(2) 1; }
  .badge-behind { animation: rgb-split 240ms steps(3) 1 .4s; }
  .card:hover .badge-behind, .card:focus-within .badge-behind { animation: rgb-split 240ms steps(3) 1; }
  .card[data-state="behind"]::after { content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(transparent 45%, color-mix(in oklch, var(--accent-crimson) 35%, transparent) 50%, transparent 55%);
    clip-path: inset(0 0 100% 0); }
  .card[data-state="behind"]:hover::after { animation: slice-sweep 320ms steps(6) 1; }
  .btn { transition: box-shadow .15s, border-color .15s; }
}

/* show page */
.h1 { font: 700 1.5rem/1.2 var(--font); margin: 0 0 .5rem; overflow-wrap: anywhere; }
.card-title a { color: var(--foreground); }
.poster-link { display: contents; }
.show-head { display: flow-root; max-width: 72ch; }
.poster-lg { width: 160px; height: 226px; float: right; margin: 0 0 .75rem 1rem; }
.show-info { min-width: 0; }
.aliases { color: var(--muted-foreground); margin: 0 0 .5rem; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .6rem; }
.lbl { grid-column: 1 / -1; font-size: .85rem; color: var(--muted-foreground); }
.ep-grid { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; grid-template-columns: 1fr; gap: .4rem; max-width: 72ch; }
.ep { display: flex; align-items: center; justify-content: flex-start; gap: .25rem; min-height: 44px; padding: 0 .75rem; border: 1px solid; border-radius: 2px;
  font: 600 .9rem var(--mono); text-decoration: none; color: var(--foreground); }
.ep-t { font: 500 .85rem var(--font); }
.ep-watched { border-color: var(--ok); color: var(--ok); background: color-mix(in oklch, var(--ok) 10%, var(--card)); }
.ep-available { border-color: var(--accent-cyan); color: var(--foreground); background: var(--card); }
.ep-upcoming { border-color: var(--muted-foreground); border-style: dashed; color: var(--muted-foreground); }
a.ep:hover { box-shadow: var(--glow-attention); }

/* cover view (?view=compact): 3 columns on phones, auto-fill up to 7 on wide screens */
.tiles { --gap: .5rem; list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap) .6rem;
  grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 30rem) {
  .tiles { grid-template-columns: repeat(auto-fill, minmax(max(104px, calc((100% - 6 * var(--gap)) / 7)), 1fr)); }
}
.tile { display: block; color: var(--foreground); text-decoration: none; border-radius: var(--radius-card); }
.tile-cover { position: relative; display: block; aspect-ratio: 2 / 3; overflow: hidden; border-radius: var(--radius-card);
  background: var(--muted); border: 1px solid var(--border); }
.tile-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-title { position: absolute; inset: auto 0 0 0; padding: 1.6rem .4rem .35rem; font: 600 .8rem/1.25 var(--font);
  color: var(--foreground); overflow-wrap: anywhere;
  background: linear-gradient(transparent, oklch(10% .03 356 / .88) 45%, oklch(10% .03 356 / .96));
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; box-sizing: content-box; height: 2.5em; }
.tile-ph { position: absolute; inset: 0; display: grid; place-items: center; padding: .5rem; text-align: center;
  font: 700 1rem/1.2 var(--font); color: var(--foreground); overflow-wrap: anywhere; overflow: hidden;
  background: linear-gradient(160deg, var(--secondary), var(--card)); border: 1px dashed var(--border); }
.tile-label { display: block; padding: .3rem .1rem 0; font: 600 .8rem/1.3 var(--mono); color: var(--muted-foreground); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.tile:hover .tile-cover, .tile:focus-visible .tile-cover { border-color: var(--accent-purple); box-shadow: var(--glow-attention); }
@media (prefers-reduced-motion: no-preference) {
  .tile:hover .tile-title, .tile:focus-visible .tile-title,
  .tile:hover .tile-ph, .tile:focus-visible .tile-ph { animation: rgb-split 240ms steps(3) 1; }
}

/* season = the unit of a card: title big, "СЕЗОН n" badge (text + notched shape) under it */
.season-line { margin: 0 0 .45rem; }
.season-badge { display: inline-block; position: relative; font: 700 .75rem/1 var(--mono); letter-spacing: .08em;
  color: var(--primary-foreground); background: var(--accent-cyan); padding: .3rem .7rem .3rem .55rem;
  clip-path: polygon(0 0, 100% 0, calc(100% - .45rem) 100%, 0 100%); }
.card-title { font-size: 1.2rem; }
.sib { position: relative; margin-left: .85rem; }
.sib::before { content: ""; position: absolute; left: -.6rem; top: -.4rem; bottom: -.4rem; width: 2px;
  background: color-mix(in oklch, var(--accent-cyan) 55%, transparent); }
.tiles > .sib::before { top: 0; bottom: 0; left: -.35rem; }
.tiles > .sib { margin-left: .35rem; }

/* episode table */
.eps { margin-top: .75rem; border-top: 1px solid var(--border); }
.eps summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--accent-cyan); }
.eps-scroll { max-width: 100%; overflow-x: auto; }
.eps-long { max-height: 22rem; overflow-y: auto; }
.eps-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.eps-table caption { text-align: left; font-weight: 700; padding: .4rem 0; color: var(--muted-foreground); overflow-wrap: anywhere; }
.eps-table th, .eps-table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.eps-table thead th { position: sticky; top: 0; background: var(--card); color: var(--muted-foreground); font: 600 .75rem var(--mono); z-index: 1; }
.eps-table .c-n { font: 600 .85rem var(--mono); width: 2.6rem; font-variant-numeric: tabular-nums; }
.eps-table .c-t { overflow-wrap: anywhere; }
.eps-table .c-st, .eps-table .c-when { white-space: nowrap; }
.ep-watched .c-st { color: var(--ok); }
.ep-unwatched .c-st { color: var(--foreground); }
.ep-upcoming .c-st, .ep-upcoming .c-t { color: var(--muted-foreground); }
.ep-upcoming .c-when { color: var(--accent-cyan); font-weight: 600; }
.ep-watched .c-when, .ep-unwatched .c-when { color: var(--muted-foreground); font-size: .8rem; }
.ep-current { background: color-mix(in oklch, var(--accent-purple) 18%, var(--card)); outline: 1px solid var(--accent-purple); outline-offset: -1px; }
.ep-next { display: inline-block; font: 700 .7rem var(--mono); color: var(--accent-purple-ink, var(--foreground)); border: 1px solid var(--accent-purple); padding: 0 .3rem; margin-left: .3rem; }
@media (max-width: 36rem) {
  .eps-table tr { display: grid; grid-template-columns: 2.4rem 1fr auto; }
  .eps-table .c-n { width: auto; }
  .eps-table .c-when { grid-column: 2 / -1; padding-top: 0; white-space: normal; }
  .eps-table thead .c-when { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); padding: 0; border: 0; }
  .eps-table .c-st { white-space: normal; }
}

/* cover view: season corner mark, label wraps, dialog panel */
.tile-season { position: absolute; left: 0; top: .4rem; z-index: 1; font: 700 .65rem/1 var(--mono); letter-spacing: .06em;
  color: var(--primary-foreground); background: var(--accent-cyan); padding: .25rem .5rem .25rem .35rem;
  clip-path: polygon(0 0, 100% 0, calc(100% - .35rem) 100%, 0 100%); }
.tile-label { white-space: normal; overflow: visible; text-overflow: clip; }
.tiles > li { display: flex; flex-direction: column; }
.tiles > li > .tile { position: relative; flex: 1; }
.tile-eps { margin-top: .35rem; min-height: 44px; width: 100%; padding: 0 .4rem; font-size: .85rem; }
.eps-dialog { width: min(100% - 1rem, 40rem); max-height: 85vh; padding: .75rem; color: var(--foreground); background: var(--card);
  border: 1px solid var(--accent-purple); border-radius: var(--radius-card); box-shadow: var(--glow-attention); overflow: auto; }
.eps-dialog::backdrop { background: oklch(8% .03 356 / .8); }
.eps-dialog form { text-align: right; margin: 0 0 .5rem; }

/* new glitch + debris: sheared noise next to the season badge, only when motion is allowed */
@keyframes badge-jitter { 0%, 100% { transform: none; } 40% { transform: translateX(2px); } 70% { transform: translateX(-1px); } }
@media (prefers-reduced-motion: no-preference) {
  .season-line { position: relative; }
  .season-line::after { content: "▞░▒ 0x7f"; position: absolute; left: 6.6rem; top: .35rem; font: .6rem/1 var(--mono);
    color: var(--accent-purple); opacity: .5; transform: translate(2px, -1px) skewX(-18deg); pointer-events: none; }
  .card:hover .season-badge, .card:focus-within .season-badge { animation: badge-jitter 200ms steps(3) 1; }
  .eps[open] .ep-current { animation: rgb-split 240ms steps(3) 1; }
  .eps-table tbody tr:nth-child(7n) td:first-child { box-shadow: 2px 0 0 color-mix(in oklch, var(--accent-purple) 40%, transparent); }
}
