:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --accent: #ff5c35;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
[data-theme="dark"] {
  --bg: #0b0b0c;
  --fg: #ededed;
  --muted: #8b8b92;
  --line: rgba(255, 255, 255, .1);
  --card: rgba(255, 255, 255, .035);
  --card-solid: #141416;
  --dot: 255, 255, 255;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f7f6f3;
  --fg: #141414;
  --muted: #6b6b70;
  --line: rgba(0, 0, 0, .1);
  --card: rgba(255, 255, 255, .6);
  --card-solid: #ffffff;
  --dot: 0, 0, 0;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color .4s var(--ease), color .4s var(--ease);
  overflow-x: hidden;
}
::selection { background: var(--accent); color: #fff; }
.accent { color: var(--accent); }

#field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
.bar, .wrap, .foot { position: relative; z-index: 1; }

/* Top bar */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(20px, 5vw, 48px);
}
.mark {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.controls { display: flex; gap: 10px; align-items: center; }
.back {
  font: 500 12px/1 var(--mono);
  color: var(--muted);
  text-decoration: none;
  padding: 8px 4px;
  transition: color .2s;
}
.back:hover { color: var(--fg); }
.lang {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: var(--card);
  backdrop-filter: blur(8px);
}
.lang button, .theme {
  font: 500 12px/1 var(--mono);
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 7px 11px;
  cursor: pointer;
  transition: color .2s, background-color .2s;
}
.lang button[aria-pressed="true"] { color: var(--bg); background: var(--fg); }
.lang button:hover:not([aria-pressed="true"]) { color: var(--fg); }
.theme {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(8px);
}
.theme:hover { color: var(--fg); }
.theme svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
[data-theme="dark"] .theme .moon, [data-theme="light"] .theme .sun { display: none; }

/* Layout */
.wrap {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px clamp(20px, 5vw, 48px) 80px;
}
.intro { max-width: 720px; margin-bottom: 48px; }
.kicker {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 18px;
  animation: fade .7s var(--ease) both;
}
.kicker::before { content: "→ "; color: var(--accent); }
.title {
  font-size: clamp(2.4rem, 7vw, 4.75rem);
  line-height: .98;
  font-weight: 650;
  letter-spacing: -.045em;
  margin: 0 0 20px;
  animation: fade .8s .08s var(--ease) both;
}
.lead {
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.55;
  max-width: 34em;
  margin: 0;
  animation: fade .8s .16s var(--ease) both;
}
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
  animation: fade .8s .24s var(--ease) both;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: 500 12px/1 var(--mono);
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: color .2s, border-color .2s, background-color .2s;
}
.chip:hover { color: var(--fg); }
.chip[aria-pressed="true"] { color: var(--bg); background: var(--fg); border-color: var(--fg); }
.count { font: 12px/1 var(--mono); color: var(--muted); }

/* Grid + cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 20px;
  perspective: 1200px;
}
.card {
  --x: 50%;
  --y: 50%;
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  backdrop-filter: blur(12px);
  overflow: hidden;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .5s var(--ease), border-color .3s, box-shadow .4s var(--ease);
  animation: cardIn .7s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 70ms + 300ms);
}
/* Uses translate/scale (not transform) so the entrance never overrides the hover tilt. */
@keyframes cardIn { from { opacity: 0; translate: 0 18px; scale: .98; } to { opacity: 1; translate: 0 0; scale: 1; } }
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(280px circle at var(--x) var(--y), rgba(255, 92, 53, .14), transparent 70%);
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.card:hover, .card:focus-within {
  border-color: rgba(255, 92, 53, .45);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .6);
}
.card:hover::after, .card:focus-within::after { opacity: 1; }
.card.hide { display: none; }

.preview {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--card-solid);
  border-bottom: 1px solid var(--line);
}
.preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 800px;
  border: 0;
  transform: scale(var(--s, .3));
  transform-origin: 0 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s var(--ease);
}
.preview iframe.ready { opacity: 1; }
.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
  transition: transform .8s var(--ease);
}
.card:hover .preview img { transform: scale(1.03); }
.preview .placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  letter-spacing: -.05em;
  color: rgba(255, 255, 255, .92);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .25), transparent 50%),
    linear-gradient(135deg, hsl(var(--h, 14) 85% 58%), hsl(calc(var(--h, 14) + 40) 80% 45%));
}
.preview .chrome {
  position: absolute;
  top: 10px;
  left: 12px;
  display: flex;
  gap: 5px;
  z-index: 1;
}
.preview .chrome i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(127, 127, 127, .45);
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px 20px;
  flex: 1;
}
.meta-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.meta h2 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0;
}
.meta .yr { font: 12px/1 var(--mono); color: var(--muted); }
.meta p {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
}
.meta-bottom {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.tags li {
  font: 11px/1 var(--mono);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
}
.open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 12px/1 var(--mono);
  color: var(--fg);
  white-space: nowrap;
}
.open svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .35s var(--ease); }
.card:hover .open { color: var(--accent); }
.card:hover .open svg { transform: translate(2px, -2px); }

/* Whole-card link sits on top of everything */
.card-link {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
}
.card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.empty {
  font-family: var(--mono);
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 48px;
  text-align: center;
}

a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Footer */
.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 24px clamp(20px, 5vw, 48px);
  font: 12px/1.4 var(--mono);
  color: var(--muted);
}
.foot a { color: inherit; text-decoration: none; }
.foot a:hover { color: var(--fg); }

.notfound { display: flex; flex-direction: column; justify-content: center; }

@media (max-width: 560px) {
  .back { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
