/* ============================================================
   Wandering Golems
   ============================================================ */

/* ── Self-hosted fonts (no third-party requests) ────────────── */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/space-grotesk-600-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/space-grotesk-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/space-grotesk-700-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/space-grotesk-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

:root {
  --bg: #1e1e1e;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-edge: rgba(255, 255, 255, 0.07);
  --cream: #f6f4e6;
  --text: rgba(246, 244, 230, 0.78);
  --text-dim: rgba(246, 244, 230, 0.5);
  --orange: #ff8f41;
  --gold: #fddb3a;
  --purple: #7963a9;
  --max-w: 880px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-accent: 'Inter', system-ui, sans-serif;
}

html {
  color-scheme: dark;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

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

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

img {
  max-width: 100%;
}

/* ── Background ─────────────────────────────────────────────── */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(30, 30, 30, 0.78), rgba(30, 30, 30, 0.86)),
    url("../img/background.webp") center / cover no-repeat;
}

/* ── Header ─────────────────────────────────────────────────── */

.site-header {
  padding: clamp(12px, 2vh, 20px) 24px 0;
}

.site-header nav {
  display: flex;
  justify-content: center;
  gap: 4px;
  width: fit-content;
  margin: 0 auto;
  padding: 4px;
  border: 1px solid var(--surface-edge);
  border-radius: 999px;
  background: rgba(30, 30, 30, 0.88);
}

.site-header a {
  font-family: var(--font-display);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 6px 18px;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}

.site-header a:hover {
  color: var(--orange);
}

.site-header a[aria-current="page"] {
  color: var(--cream);
  background: var(--purple);
}

/* ── Layout ─────────────────────────────────────────────────── */

main {
  width: min(100% - 2.5rem, var(--max-w));
  margin-inline: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page-head {
  text-align: center;
  padding: clamp(20px, 4vh, 40px) 0 clamp(16px, 3vh, 28px);
}

.page-title {
  font-family: var(--font-display);
  color: var(--cream);
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.page-title::after {
  content: "";
  display: block;
  width: 56px;
  height: 2px;
  margin: 12px auto 0;
  background: linear-gradient(90deg, var(--orange), var(--gold));
  border-radius: 2px;
}

.page-sub {
  margin-top: 10px;
  color: var(--text-dim);
  font-family: var(--font-accent);
  font-size: 0.95rem;
}

/* ── One-screen pages (home, articles) ──────────────────────── */
/* Content is sized to fit; on short/narrow viewports the page
   degrades to normal scrolling instead of clipping content.   */

@media (min-width: 641px) and (min-height: 701px) {
  body.fit {
    height: 100dvh;
    overflow: hidden;
  }
}

body.fit main {
  justify-content: center;
}

/* ── Home ───────────────────────────────────────────────────── */

.hero {
  text-align: center;
  padding: clamp(8px, 2vh, 24px) 0 clamp(16px, 3vh, 32px);
}

.hero img {
  width: clamp(96px, 18vh, 150px);
  height: auto;
  margin-bottom: clamp(10px, 2vh, 20px);
}

.hero h1 {
  font-family: var(--font-display);
  color: var(--cream);
  font-size: clamp(1.7rem, 4.5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.hero .tagline {
  font-family: var(--font-accent);
  color: var(--text-dim);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  margin-top: 6px;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface-edge);
  border-left: 3px solid var(--purple);
  border-radius: 10px;
  padding: clamp(16px, 2.5vh, 24px) clamp(18px, 2.5vw, 28px);
}

.card h2 {
  font-family: var(--font-display);
  color: var(--cream);
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.card p {
  font-size: 0.92rem;
  color: var(--text);
}

/* ── Latest post (home) ─────────────────────────────────────── */

.latest {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding: 12px 20px 12px 12px;
  background: var(--surface);
  border: 1px solid var(--surface-edge);
  border-left: 3px solid var(--purple);
  border-radius: 10px;
  text-decoration: none;
  transition: border-color 0.25s, translate 0.25s;
}

.latest:hover {
  border-left-color: var(--orange);
  translate: 4px 0;
}

.latest img {
  width: clamp(48px, 8vh, 64px);
  height: clamp(48px, 8vh, 64px);
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.latest-label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.latest-title {
  display: block;
  font-family: var(--font-display);
  color: var(--cream);
  font-size: 1rem;
  font-weight: 600;
  transition: color 0.2s;
}

.latest:hover .latest-title {
  color: var(--orange);
}

.latest-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.latest-arrow {
  margin-left: auto;
  color: var(--orange);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ── Articles listing ───────────────────────────────────────── */

.post-list {
  display: grid;
  gap: 16px;
  align-content: start;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--purple) transparent;
  padding-bottom: 8px;
}

.post-card {
  display: block;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--surface-edge);
  border-left: 3px solid var(--purple);
  border-radius: 10px;
  padding: 22px 28px;
  transition: border-color 0.25s, translate 0.25s;
}

.post-card:hover {
  border-left-color: var(--orange);
  translate: 4px 0;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.post-date {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-transform: uppercase;
}

.post-tag {
  font-size: 0.68rem;
  padding: 2px 10px;
  border: 1px solid var(--purple);
  color: var(--purple);
  border-radius: 20px;
  font-family: var(--font-accent);
}

.post-title {
  font-family: var(--font-display);
  color: var(--cream);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 6px;
  transition: color 0.2s;
}

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

.post-excerpt {
  color: var(--text);
  font-size: 0.9rem;
}

.post-arrow {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--orange);
  text-transform: uppercase;
}

/* ── Post page ──────────────────────────────────────────────── */

.article {
  max-width: 72ch;
  margin: clamp(20px, 4vh, 44px) auto;
  background: rgba(30, 30, 30, 0.9);
  border: 1px solid var(--surface-edge);
  border-radius: 14px;
  padding: clamp(24px, 4vw, 48px) clamp(20px, 5vw, 56px);
}

.back-link {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--orange);
  text-decoration: none;
  margin-bottom: 24px;
}

.back-link:hover {
  color: var(--gold);
}

.article > h1 {
  font-family: var(--font-display);
  color: var(--cream);
  font-size: clamp(1.45rem, 3.2vw, 2rem);
  line-height: 1.3;
  margin: 10px 0 18px;
}

.article-divider {
  width: 56px;
  height: 2px;
  background: linear-gradient(90deg, var(--orange), var(--gold));
  border-radius: 2px;
  margin-bottom: 24px;
}

.article > p {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.85;
  margin-bottom: 18px;
}

.article > img {
  display: block;
  max-width: min(100%, 480px);
  height: auto;
  margin: 28px auto;
  border-radius: 10px;
  border: 1px solid var(--surface-edge);
}

.article > h2 {
  font-family: var(--font-display);
  color: var(--purple);
  font-size: 1.15rem;
  margin: 30px 0 10px;
}

.article > blockquote {
  border-left: 3px solid var(--gold);
  margin: 24px 0;
  padding: 12px 20px;
  background: rgba(253, 219, 58, 0.05);
  border-radius: 0 8px 8px 0;
}

.article > blockquote p {
  font-family: var(--font-accent);
  color: var(--cream);
  margin: 0;
}

.article a {
  color: var(--orange);
}

.article a:hover {
  color: var(--gold);
}

/* ── Gallery ────────────────────────────────────────────────── */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  padding-bottom: 48px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--surface-edge);
  border-radius: 12px;
  cursor: zoom-in;
  font: inherit;
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.gallery-item:hover {
  transform: translateY(-4px);
  border-color: var(--orange);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.gallery-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item .cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22px 12px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--cream);
  text-align: center;
}

/* ── Lightbox (native <dialog>) ─────────────────────────────── */

.lightbox {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(92vw, 860px);
  max-height: 92dvh;
  margin: auto;
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.86);
}

.lightbox figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.lightbox img {
  max-width: 100%;
  max-height: 68dvh;
  width: auto;
  object-fit: contain;
  border-radius: 10px 10px 0 0;
  background: rgba(30, 30, 30, 0.6);
}

.lightbox figcaption {
  width: 100%;
  background: rgba(38, 38, 38, 0.96);
  border: 1px solid var(--surface-edge);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 14px 22px;
  text-align: center;
}

.lb-title {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--cream);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.lb-desc {
  color: var(--text);
  font-size: 0.88rem;
  margin-top: 4px;
}

.lb-desc:empty {
  display: none;
}

.lb-post {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange);
  text-decoration: none;
}

.lb-post:hover {
  color: var(--gold);
}

.lb-btn {
  position: fixed;
  border: 1px solid var(--surface-edge);
  background: rgba(30, 30, 30, 0.8);
  color: var(--cream);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.lb-btn:hover {
  color: var(--orange);
  border-color: var(--orange);
}

.lb-close {
  top: 18px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
}

.lb-prev,
.lb-next {
  top: 50%;
  translate: 0 -50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
}

.lb-prev {
  left: 20px;
}

.lb-next {
  right: 20px;
}

/* ── No-JS gallery fallback ─────────────────────────────────── */

.noscript-list {
  margin: 16px 0 40px;
  padding-left: 20px;
  color: var(--text);
}

.noscript-list a {
  color: var(--orange);
}

/* ── Footer ─────────────────────────────────────────────────── */

footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: clamp(14px, 2.5vh, 24px) 24px;
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

footer .sep {
  color: var(--purple);
}

footer a {
  color: var(--orange);
  text-decoration: none;
  font-weight: 500;
}

footer a:hover {
  color: var(--gold);
}

/* ── Small screens ──────────────────────────────────────────── */

@media (max-width: 640px) {
  .about-grid {
    grid-template-columns: 1fr;
  }

  .latest {
    gap: 12px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .lb-prev {
    left: 8px;
  }

  .lb-next {
    right: 8px;
  }
}

/* ── Reduced motion ─────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
