/* =========================================================================
   WilyWise — site styles
   No web fonts, no external requests. Everything is system-native so pages
   render instantly and never leak a visitor to a third party.
   ========================================================================= */

/* ---------------------------------------------------------------- tokens */

:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-serif: "Iowan Old Style", "Charter", "Palatino Linotype", "Book Antiqua",
    Palatino, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Segoe UI Mono",
    Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #fbfaf8;
  --bg-soft: #f4f1ec;
  --surface: #ffffff;
  --surface-2: #f7f4ef;
  --text: #17181c;
  --text-soft: #3c3d44;
  --muted: #6a6b73;
  --line: #e5e0d7;
  --line-strong: #d3ccc0;
  --accent: #0d6b57;
  --accent-soft: #e3f0eb;
  --accent-contrast: #ffffff;
  --shadow: 0 1px 2px rgb(20 20 25 / 6%), 0 12px 32px -12px rgb(20 20 25 / 12%);
  --shadow-lg: 0 2px 4px rgb(20 20 25 / 8%), 0 28px 64px -24px rgb(20 20 25 / 22%);
  --radius: 12px;
  --radius-lg: 18px;
  --wrap: 74rem;
  --wrap-narrow: 43rem;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="dark"] {
  --bg: #101114;
  --bg-soft: #17181d;
  --surface: #16171c;
  --surface-2: #1c1d23;
  --text: #ececf0;
  --text-soft: #c8c9d1;
  --muted: #9a9ba6;
  --line: #26272e;
  --line-strong: #34353d;
  --accent: #7fd6ba;
  --accent-soft: #14312a;
  --accent-contrast: #06231c;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 18px 40px -18px rgb(0 0 0 / 60%);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / 45%), 0 32px 72px -28px rgb(0 0 0 / 75%);
}

/* No-JS fallback: honour the OS preference when the bootstrap script is blocked. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101114;
    --bg-soft: #17181d;
    --surface: #16171c;
    --surface-2: #1c1d23;
    --text: #ececf0;
    --text-soft: #c8c9d1;
    --muted: #9a9ba6;
    --line: #26272e;
    --line-strong: #34353d;
    --accent: #7fd6ba;
    --accent-soft: #14312a;
    --accent-contrast: #06231c;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 18px 40px -18px rgb(0 0 0 / 60%);
    --shadow-lg: 0 2px 6px rgb(0 0 0 / 45%), 0 32px 72px -28px rgb(0 0 0 / 75%);
  }
}

/* ---------------------------------------------------------------- reset */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.viewer-open {
  overflow: hidden;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.06em;
}

a:hover {
  color: var(--accent);
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

/* -------------------------------------------------------------- layout */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.15rem, 4vw, 2.5rem);
}

.wrap-narrow {
  width: 100%;
  max-width: var(--wrap-narrow);
  margin-inline: auto;
  padding-inline: clamp(1.15rem, 4vw, 2.5rem);
}

.site-main {
  flex: 1 0 auto;
  padding-bottom: clamp(3rem, 8vw, 6rem);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: 0.7rem 1rem;
  border-radius: 0 0 var(--radius) 0;
  z-index: 200;
  box-shadow: var(--shadow);
}

.skip-link:focus {
  left: 0;
}

/* -------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 3.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 1.02rem;
  margin-right: auto;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #f0b429));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.35rem;
  font-size: 0.9rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--muted);
  padding-block: 0.35rem;
  border-bottom: 1px solid transparent;
  transition: color 0.18s var(--ease);
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.theme-toggle svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.icon-sun {
  display: none;
}

.icon-sun circle,
.icon-moon path {
  fill: none;
}

:root[data-theme="dark"] .icon-sun {
  display: block;
}

:root[data-theme="dark"] .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun {
    display: block;
  }
  :root:not([data-theme="light"]) .icon-moon {
    display: none;
  }
}

/* ---------------------------------------------------------------- hero */

.hero {
  padding-block: clamp(3rem, 8vw, 6rem) clamp(2rem, 4vw, 3rem);
}

.kicker {
  margin: 0 0 1.1rem;
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2.15rem, 6.2vw, 4rem);
  line-height: 1.06;
  letter-spacing: -0.022em;
  max-width: 20ch;
  text-wrap: balance;
}

.hero-lede {
  margin: 1.5rem 0 0;
  max-width: 46ch;
  font-size: clamp(1.02rem, 1.6vw, 1.18rem);
  color: var(--text-soft);
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 2.1rem 0 0;
}

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

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.62rem 1.15rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.92rem;
  font-weight: 560;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.button:hover {
  color: var(--accent-contrast);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 60%, transparent);
}

.button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}

.button.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: none;
}

.button.small {
  padding: 0.42rem 0.85rem;
  font-size: 0.82rem;
}

.button-note {
  opacity: 0.75;
  font-size: 0.8em;
}

/* ------------------------------------------------------------- sections */

.section {
  margin-top: clamp(2rem, 5vw, 3.5rem);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.25rem;
}

.section-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--font-sans);
}

.more {
  font-size: 0.88rem;
  color: var(--muted);
  text-decoration: none;
}

.more:hover {
  color: var(--accent);
}

.page-header {
  padding-block: clamp(2.8rem, 7vw, 4.5rem) clamp(1.6rem, 4vw, 2.4rem);
}

.page-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2rem, 4.6vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.lede {
  margin: 1rem 0 0;
  max-width: 52ch;
  color: var(--text-soft);
  font-size: 1.02rem;
}

.empty {
  color: var(--muted);
  padding: 2rem 0;
}

/* ---------------------------------------------------------- post list */

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: clamp(1.4rem, 3vw, 1.9rem) 0;
  border-bottom: 1px solid var(--line);
}

.post-card:hover .card-title a {
  color: var(--accent);
}

.card-media {
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 16 / 9;
  transition: transform 0.5s var(--ease);
}

.post-card:hover .card-media img {
  transform: scale(1.02);
}

.card-body {
  min-width: 0;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.dot {
  opacity: 0.6;
}

.card-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 2.2vw, 1.42rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.012em;
}

.card-title a {
  text-decoration: none;
}

.card-summary {
  margin: 0.5rem 0 0;
  color: var(--text-soft);
  font-size: 0.94rem;
  max-width: 60ch;
}

.badge {
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.14rem 0.42rem;
  border-radius: 4px;
}

.badge.draft {
  background: var(--accent-soft);
  color: var(--accent);
}

.year-group {
  margin-top: 2.6rem;
}

.year {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
  padding-bottom: 0.6rem;
}

@media (min-width: 46rem) {
  .post-card {
    grid-template-columns: 1fr;
  }
  .post-card:has(.card-media) {
    grid-template-columns: minmax(0, 1fr) 12rem;
    align-items: start;
    gap: 1.6rem;
  }
  .post-card:has(.card-media) .card-media {
    grid-column: 2;
    grid-row: 1;
  }
  .post-card:has(.card-media) .card-body {
    grid-column: 1;
    grid-row: 1;
  }
}

/* --------------------------------------------------------------- post */

.post-header {
  padding-block: clamp(2.6rem, 6vw, 4.2rem) 1.6rem;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.post-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3.15rem);
  line-height: 1.08;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

.post-summary {
  margin: 1.15rem 0 0;
  font-size: clamp(1.02rem, 1.5vw, 1.14rem);
  color: var(--text-soft);
  line-height: 1.6;
  max-width: 54ch;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 1.4rem 0 0;
  padding: 0;
}

.tag {
  display: inline-block;
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.16rem 0.6rem;
  background: var(--surface);
}

.post-cover {
  margin: 0 auto 2.6rem;
  padding: 0;
}

.post-cover img {
  width: 100%;
  border-radius: var(--radius-lg);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-2);
}

.post-gallery {
  margin-top: 3rem;
}

.post-footer {
  margin-top: 3.2rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--line);
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-decoration: none;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.post-nav-link:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  color: var(--text);
}

.post-nav-link.next {
  text-align: right;
  align-items: flex-end;
}

.nav-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-title {
  font-family: var(--font-serif);
  font-size: 0.98rem;
  line-height: 1.3;
}

.post-back {
  margin: 2rem 0 0;
  font-size: 0.88rem;
}

.post-back a {
  color: var(--muted);
  text-decoration: none;
}

/* -------------------------------------------------------------- prose */

.prose {
  font-family: var(--font-serif);
  font-size: clamp(1.04rem, 1.25vw, 1.12rem);
  line-height: 1.78;
  color: var(--text);
  letter-spacing: 0.001em;
}

.prose > * + * {
  margin-top: 1.25em;
}

.prose p {
  margin: 0;
}

.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--font-sans);
  font-weight: 640;
  letter-spacing: -0.012em;
  line-height: 1.25;
  margin-top: 2.4em;
  margin-bottom: 0.2em;
  scroll-margin-top: 5rem;
}

.prose h2 {
  font-size: 1.42em;
}

.prose h3 {
  font-size: 1.16em;
}

.prose h4 {
  font-size: 1em;
  color: var(--text-soft);
}

.heading-anchor {
  margin-left: 0.4rem;
  color: var(--line-strong);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}

.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
}

.prose a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent);
  text-decoration-thickness: 0.055em;
  text-underline-offset: 0.17em;
}

.prose a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.prose strong {
  font-weight: 650;
}

.prose ul,
.prose ol {
  margin: 1.2em 0;
  padding-left: 1.3em;
}

.prose li + li {
  margin-top: 0.45em;
}

.prose li::marker {
  color: var(--muted);
}

.prose blockquote {
  margin: 1.8em 0;
  padding: 0.2em 0 0.2em 1.3em;
  border-left: 2px solid var(--accent);
  color: var(--text-soft);
  font-style: italic;
}

.prose blockquote p + p {
  margin-top: 0.8em;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.12em 0.34em;
}

.prose pre.code {
  position: relative;
  margin: 1.7em 0;
  padding: 1.05rem 1.15rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.6;
  tab-size: 2;
}

.prose pre.code code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 1em;
}

.prose pre.code[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.5rem;
  right: 0.7rem;
  font-family: var(--font-sans);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.75;
}

.prose table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  margin: 1.6em 0;
}

.prose th,
.prose td {
  border-bottom: 1px solid var(--line);
  padding: 0.55em 0.9em;
  text-align: left;
  vertical-align: top;
}

.prose th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.prose img {
  border-radius: var(--radius);
}

.figure {
  margin: 2em 0;
}

.figure img {
  width: 100%;
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: zoom-in;
}

.figure figcaption,
.gallery figcaption {
  margin-top: 0.7em;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.prose .figure figcaption {
  font-style: italic;
}

.prose hr {
  margin: 3em 0;
}

.prose-small {
  font-size: 0.98rem;
}

/* ------------------------------------------------------------ gallery */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr));
  gap: 0.8rem;
}

.gallery-item {
  margin: 0;
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: var(--surface-2);
  cursor: zoom-in;
  transition: filter 0.3s var(--ease), transform 0.4s var(--ease);
}

.gallery-item img:hover {
  filter: brightness(1.04) saturate(1.03);
  transform: translateY(-2px);
}

/* ---------------------------------------------------------- downloads */

.downloads {
  display: grid;
  gap: clamp(1.4rem, 3vw, 2.4rem);
}

.download-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.4rem;
  padding: clamp(1.1rem, 2.6vw, 1.7rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  scroll-margin-top: 5rem;
}

.download-media {
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.download-media img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  cursor: zoom-in;
  transition: transform 0.5s var(--ease);
}

.download-card:hover .download-media img {
  transform: scale(1.015);
}

.download-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 2.4vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.014em;
  line-height: 1.2;
}

.download-summary {
  margin: 0.6rem 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.9rem 1.2rem;
  margin: 1.35rem 0 0;
}

.facts dt {
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.facts dd {
  margin: 0;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 1.4rem 0 0;
}

.hash {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0.9rem 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.hash-label {
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.62rem;
}

.hash code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.download-notes {
  grid-column: 1 / -1;
  padding-top: 1.3rem;
  border-top: 1px solid var(--line);
  color: var(--text-soft);
}

.download-notes > *:first-child {
  margin-top: 0;
}

.copy-hash[data-copied="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

@media (min-width: 52rem) {
  .download-card {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    align-items: start;
    gap: 2rem;
  }
  .download-media {
    grid-row: span 2;
  }
  .download-notes {
    border-top: 1px solid var(--line);
    padding-top: 1.2rem;
    margin-top: 0.2rem;
  }
}

/* ------------------------------------------------------- feature card */

.feature-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
  align-items: center;
  margin-top: 1.4rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.feature-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  color: inherit;
}

.feature-media {
  border-radius: var(--radius);
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface-2);
}

.feature-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.2rem 0.4rem 0.4rem;
}

.feature-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.feature-summary {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.feature-meta {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

@media (min-width: 46rem) {
  .feature-card {
    grid-template-columns: 16rem minmax(0, 1fr);
    padding: 0.9rem;
  }
  .feature-media {
    aspect-ratio: 4 / 3;
  }
}

/* ----------------------------------------------------------------- tags */

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.tag-cloud a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  background: var(--surface);
}

.tag-cloud a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tag-cloud .count {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 404 */

.notfound {
  text-align: center;
  padding-block: clamp(4rem, 12vw, 8rem);
}

.notfound .hero-title,
.notfound .hero-lede {
  margin-inline: auto;
}

.notfound .hero-actions {
  justify-content: center;
}

/* ------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding-block: 1.6rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem 1.5rem;
}

.footer-inner p {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 1.2rem;
}

.footer-links a {
  text-decoration: none;
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--accent);
}

/* --------------------------------------------------- copy feedback toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  transform: translate(-50%, 1rem);
  background: var(--text);
  color: var(--bg);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  z-index: 300;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------ lightbox */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #08090b;
  color: #f4f4f6;
  opacity: 0;
  transition: opacity 0.22s var(--ease);
}

.viewer[hidden] {
  display: none;
}

.viewer.is-open {
  opacity: 1;
}

.viewer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(0.9rem, 3vw, 1.6rem);
  font-size: 0.82rem;
  color: rgb(255 255 255 / 72%);
}

.viewer-counter {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.viewer-btn {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 16%);
  background: rgb(255 255 255 / 6%);
  color: #f4f4f6;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.viewer-btn:hover {
  background: rgb(255 255 255 / 14%);
  border-color: rgb(255 255 255 / 32%);
}

.viewer-btn:active {
  transform: scale(0.96);
}

.viewer-btn svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.viewer-download {
  text-decoration: none;
}

.viewer-stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.viewer-stage.is-zoomed {
  cursor: grab;
}

.viewer-stage.is-panning {
  cursor: grabbing;
}

.viewer-image {
  max-width: min(94vw, 1500px);
  max-height: calc(100dvh - 9.5rem);
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / 80%);
  transform-origin: center center;
  transition: transform 0.18s var(--ease);
  user-select: none;
  -webkit-user-drag: none;
}

.viewer-image.is-zoomed {
  transition: none;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.9rem;
  height: 2.9rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 14%);
  background: rgb(10 10 12 / 55%);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  opacity: 0.85;
}

.viewer-nav:hover {
  opacity: 1;
  background: rgb(10 10 12 / 80%);
}

.viewer-nav.prev {
  left: clamp(0.6rem, 2vw, 1.4rem);
}

.viewer-nav.next {
  right: clamp(0.6rem, 2vw, 1.4rem);
}

.viewer-nav[disabled] {
  opacity: 0.25;
  cursor: default;
}

.viewer-nav svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.viewer-bottom {
  padding: 0.7rem clamp(0.9rem, 3vw, 1.6rem) 1.1rem;
  text-align: center;
  min-height: 3.4rem;
}

.viewer-caption {
  margin: 0;
  font-size: 0.86rem;
  color: rgb(255 255 255 / 78%);
  max-width: 70ch;
  margin-inline: auto;
}

.viewer-hint {
  margin: 0.25rem 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: rgb(255 255 255 / 42%);
}

.viewer-thumbs {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  padding: 0 clamp(0.9rem, 3vw, 1.6rem) 0.9rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.viewer-thumb {
  width: 3.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  background: none;
  cursor: pointer;
  opacity: 0.5;
  flex: 0 0 auto;
}

.viewer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.viewer-thumb[aria-current="true"] {
  opacity: 1;
  border-color: rgb(255 255 255 / 70%);
}

.viewer-thumbs:empty {
  display: none;
}

body.viewer-open .site-header {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

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

@media (max-width: 40rem) {
  .site-nav {
    gap: 0.95rem;
    font-size: 0.85rem;
  }
  .brand-name {
    font-size: 0.98rem;
  }
  .post-nav {
    grid-template-columns: 1fr;
  }
  .post-nav-link.next {
    text-align: left;
    align-items: flex-start;
  }
  .viewer-image {
    max-width: 96vw;
    max-height: calc(100dvh - 10.5rem);
  }
  .viewer-thumbs {
    display: none;
  }
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ------------------------------------------------------ motion & print */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .post-nav,
  .viewer,
  .theme-toggle,
  .hero-actions {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .prose {
    max-width: none;
  }
}
