/* ------------------------------------------------------------------
   Tokens
------------------------------------------------------------------ */
:root {
  --bg:           #f4f0e6;
  --bg-elevated:  #fbf8f1;
  --bg-sunk:      #ece7d8;
  --ink:          #1a1714;
  --ink-soft:     #5a554d;
  --ink-faint:    #9a948a;
  --rule:         #ddd6c4;
  --rule-strong:  #c4bca7;

  --serif: 'Fraunces', 'Iowan Old Style', 'Hoefler Text', Georgia, serif;
  --sans:  'Geist', 'Helvetica Neue', system-ui, -apple-system, sans-serif;
  --mono:  'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace;

  --shadow-card:  0 1px 0 0 rgba(26, 23, 20, 0.04);
  --shadow-hover: 0 24px 60px -28px rgba(26, 23, 20, 0.22);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --max-w: 1240px;
  --gutter: clamp(20px, 4vw, 56px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0e0d0c;
    --bg-elevated: #181614;
    --bg-sunk:     #131110;
    --ink:         #f0ece4;
    --ink-soft:    #a8a29a;
    --ink-faint:   #6b665e;
    --rule:        #2a2824;
    --rule-strong: #3a3631;
    --shadow-card:  0 1px 0 0 rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 24px 60px -28px rgba(0, 0, 0, 0.7);
  }
}

[data-theme="dark"] {
  --bg:          #0e0d0c;
  --bg-elevated: #181614;
  --bg-sunk:     #131110;
  --ink:         #f0ece4;
  --ink-soft:    #a8a29a;
  --ink-faint:   #6b665e;
  --rule:        #2a2824;
  --rule-strong: #3a3631;
  --shadow-card:  0 1px 0 0 rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 24px 60px -28px rgba(0, 0, 0, 0.7);
}

/* ------------------------------------------------------------------
   Base
------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.45s var(--ease), color 0.45s var(--ease);
}

a { color: inherit; }

::selection {
  background: var(--ink);
  color: var(--bg);
}

/* Subtle film grain over the whole page */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
}
[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: 0.05; }

/* ------------------------------------------------------------------
   Header
------------------------------------------------------------------ */
.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px var(--gutter) 10px;
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.brand-name {
  font-family: var(--serif);
  font-weight: 500;
  font-style: italic;
  font-size: 22px;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 24;
}

.brand-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

@media (max-width: 520px) {
  .brand-meta { display: none; }
}

/* Theme toggle */
.theme-toggle {
  appearance: none;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.theme-toggle:hover { border-color: var(--rule-strong); background: var(--bg-elevated); }
.theme-toggle:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 12%, transparent);
}
.theme-toggle-icon { display: inline-flex; width: 16px; height: 16px; }
.theme-toggle-icon svg { width: 16px; height: 16px; transition: opacity 0.3s var(--ease), transform 0.4s var(--ease); position: absolute; }
.theme-toggle-icon { position: relative; }
.icon-sun  { opacity: 1; transform: rotate(0); }
.icon-moon { opacity: 0; transform: rotate(-40deg); }
[data-theme="dark"] .icon-sun  { opacity: 0; transform: rotate(40deg); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: rotate(0); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun  { opacity: 0; transform: rotate(40deg); }
  :root:not([data-theme="light"]) .icon-moon { opacity: 1; transform: rotate(0); }
}

/* ------------------------------------------------------------------
   Main / intro
------------------------------------------------------------------ */
main {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.intro {
  padding: clamp(14px, 2vw, 22px) 0 clamp(10px, 1.6vw, 16px);
  max-width: 720px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 10px;
}
.eyebrow-rule {
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--rule-strong);
}

.lede {
  font-family: var(--serif);
  font-weight: 360;
  font-style: normal;
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.022em;
  margin: 0 0 8px;
  color: var(--ink);
  font-variation-settings: "opsz" 96;
}
.lede em {
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "opsz" 96;
}

.sub {
  font-family: var(--serif);
  font-weight: 350;
  font-size: clamp(15px, 1.2vw, 16.5px);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 56ch;
  font-variation-settings: "opsz" 18;
}

/* ------------------------------------------------------------------
   Apps grid
------------------------------------------------------------------ */
.apps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr));
  gap: 14px;
  padding: 4px 0 28px;
}

@media (min-width: 1100px) {
  .apps { grid-template-columns: repeat(2, 1fr); }
}

.card {
  --app-accent: #888;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 18px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  isolation: isolate;
  box-shadow: var(--shadow-card);
  transition:
    transform 0.5s var(--ease),
    border-color 0.4s var(--ease),
    box-shadow 0.5s var(--ease);
  opacity: 0;
  transform: translateY(14px);
  animation: cardIn 0.7s var(--ease) forwards;
  animation-delay: var(--stagger, 0ms);
}

@keyframes cardIn {
  to { opacity: 1; transform: translateY(0); }
}

.card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--app-accent) 55%, var(--rule));
  box-shadow: var(--shadow-hover);
}

.card:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 14%, transparent);
}

/* Card top: index, rule, arrow */
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}
.card-index {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.card-index-rule {
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--rule-strong);
  transition: width 0.5s var(--ease), background 0.4s var(--ease);
}
.card:hover .card-index-rule {
  width: 56px;
  background: var(--app-accent);
}

.card-arrow {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: background 0.35s var(--ease), color 0.35s var(--ease),
              border-color 0.35s var(--ease), transform 0.45s var(--ease);
}
.card-arrow svg { width: 11px; height: 11px; transition: transform 0.45s var(--ease); }
.card:hover .card-arrow {
  background: var(--app-accent);
  color: #fff;
  border-color: var(--app-accent);
  transform: rotate(-2deg);
}
.card:hover .card-arrow svg {
  transform: translate(1px, -1px);
}

/* Thumb */
.card-thumb {
  position: relative;
  margin: 8px 16px 0;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 5 / 1;
  background: var(--bg-sunk);
  border: 1px solid var(--rule);
  transition: aspect-ratio 0.55s var(--ease);
}

.card:hover .card-thumb,
.card:focus-visible .card-thumb {
  aspect-ratio: 16 / 9;
}

/* In the 2-col layout, also grow the row-mate's thumbnail so the
   row stays visually balanced when one card is being hovered. */
@media (min-width: 1100px) {
  .card:nth-child(odd):hover + .card .card-thumb,
  .card:nth-child(odd):has(+ .card:hover) .card-thumb {
    aspect-ratio: 16 / 9;
  }
}

.card-thumb img,
.card-thumb svg.placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.9s var(--ease), filter 0.6s var(--ease);
}
.card:hover .card-thumb img,
.card:hover .card-thumb svg.placeholder {
  transform: scale(1.035);
}

/* A subtle accent wash on hover */
.card-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 60%,
    color-mix(in srgb, var(--app-accent) 28%, transparent) 100%
  );
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}
.card:hover .card-thumb::after { opacity: 1; }

/* Card body */
.card-body {
  padding: 12px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-headline {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title {
  font-family: var(--serif);
  font-weight: 420;
  font-size: 22px;
  letter-spacing: -0.018em;
  line-height: 1.05;
  color: var(--ink);
  font-variation-settings: "opsz" 30;
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
}
.card-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--app-accent);
  transform: translateY(-2px);
  transition: transform 0.45s var(--ease), box-shadow 0.45s var(--ease);
}
.card:hover .card-dot {
  transform: translateY(-2px) scale(1.3);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--app-accent) 22%, transparent);
}
.card-tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink-soft);
  font-variation-settings: "opsz" 16;
}

.card-desc {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-2px);
  transition:
    max-height 0.55s var(--ease),
    opacity 0.35s var(--ease),
    transform 0.45s var(--ease),
    margin 0.55s var(--ease);
}

.card:hover .card-desc,
.card:focus-visible .card-desc {
  max-height: 220px;
  opacity: 1;
  margin: 6px 0 2px;
  transform: translateY(0);
  transition:
    max-height 0.55s var(--ease),
    opacity 0.4s var(--ease) 0.1s,
    transform 0.5s var(--ease) 0.05s,
    margin 0.55s var(--ease);
}

/* Touch / no-hover devices: always show full content */
@media (hover: none) {
  .card-thumb { aspect-ratio: 16 / 9; }
  .card-desc {
    max-height: none;
    opacity: 1;
    margin: 6px 0 2px;
    transform: none;
  }
}

/* Card footer: url + year */
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding: 8px 16px 10px;
  border-top: 1px dashed var(--rule);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.card-url {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.card-url-host {
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
}
.card:hover .card-url-host { color: var(--app-accent); }
.card-year {
  flex-shrink: 0;
  margin-left: 12px;
}

/* ------------------------------------------------------------------
   Footer
------------------------------------------------------------------ */
.site-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: auto;
  padding: 0 var(--gutter) 18px;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}
.footer-rule {
  display: block;
  height: 1px;
  background: var(--rule);
  margin-bottom: 14px;
}
.footer-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px 36px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.footer-cell { display: inline-flex; gap: 10px; align-items: baseline; }
.footer-key {
  color: var(--ink-faint);
  opacity: 0.7;
}
.footer-val { color: var(--ink-soft); }
.footer-val a { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule-strong); }
.footer-val a:hover { color: var(--ink); text-decoration-color: var(--ink); }

/* ------------------------------------------------------------------
   Reduced motion
------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .card { opacity: 1; transform: none; }
}
