/* ============================================================
   neithan.rocks — black luxury + glassmorphic + muted gold
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Noto+Serif+JP:wght@300;400;500;600&family=Shippori+Mincho+B1:wght@200;300;400;500&family=Shizuru&family=Yuji+Mai&display=swap");

:root {
  --bg: #0a0a0a;
  --bg-deeper: #050505;
  --surface: rgba(255, 255, 255, 0.025);
  --surface-hover: rgba(255, 255, 255, 0.045);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8e6e0;
  --text-dim: #8a8680;
  --text-faint: #555049;

  --gold: #a89968;
  --gold-soft: #8a7c55;
  --gold-bright: #c7b680;
  --gold-glow: rgba(168, 153, 104, 0.28);
  --gold-glow-soft: rgba(168, 153, 104, 0.12);

  /* Royal Enfield Tokyo Black red — used sparingly as hanko-style accent */
  --red: #c42c2c;
  --red-dim: #8a1f1f;
  --red-glow: rgba(196, 44, 44, 0.35);

  --font-display: "Shizuru", "Yuji Mai", "Permanent Marker", cursive;
  --font-jp: "Shippori Mincho B1", "Noto Serif JP", serif;
  --font-body: "Noto Serif JP", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-label: "Inter", sans-serif;

  --radius: 14px;
  --radius-sm: 8px;

  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-featured: 0 0 0 1px rgba(168, 153, 104, 0.35),
    0 0 40px -8px var(--gold-glow), 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15.5px;
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* prevent any stray horizontal scroll without breaking position: sticky */
html {
  overflow-x: clip;
}

body {
  position: relative;
}

#circuit-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 32px 120px;
}

/* -------- Header (sticky, shrinks on scroll) -------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  /* no direct backdrop-filter on the header itself — it's on .header-glass
     (a separate absolutely-positioned layer whose opacity is animated).
     Transitioning backdrop-filter causes flicker on Chromium. */
}

.header-glass {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  /* Smaller blur radius = fewer pixels sampled per frame = much cheaper
     to repaint during scroll. Still reads as glass. */
  backdrop-filter: blur(8px) saturate(125%);
  -webkit-backdrop-filter: blur(8px) saturate(125%);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  z-index: 0;
}

.site-header.scrolled .header-glass {
  opacity: 1;
}

.header-inner {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 26px 32px 16px;
  border-bottom: 1px solid var(--border);
  transition: padding 0.18s cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 0.18s ease;
}

.site-header.scrolled .header-inner {
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom-color: var(--border-strong);
}

.header-top-row {
  display: flex;
  align-items: flex-end;
  /* no gap — the .header-spacer (flex-grow 1 at rest) handles the push
     between brand and nav, and we use margin-left on the filter-bar only
     when it's visible. Gap-based spacing around 0-width items was eating
     a huge chunk of mobile header width. */
  gap: 0;
  min-width: 0;
}

.brand-group {
  min-width: 0;
}

.site-header .brand {
  transition: font-size 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.site-header.scrolled .brand {
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
}

.tagline {
  max-height: 2em;
  overflow: hidden;
  transition: opacity 0.15s ease, max-height 0.18s ease,
    margin-top 0.18s ease;
}

.site-header.scrolled .tagline {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
  pointer-events: none;
}

.brand-group {
  flex: 0 0 auto;
  min-width: 0;
}

/* A zero-width flex spacer. At rest it has flex-grow: 1 which pushes the
   nav to the right edge. On scroll it transitions to flex-grow: 0 while
   the filter-bar transitions from 0 → 1 — space swaps smoothly between
   them with no snap, no auto-margin trick, no delay needed. */
.header-spacer {
  flex: 1 1 0;
  min-width: 0;
  align-self: stretch;
  transition: flex-grow 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.site-header.scrolled .header-spacer {
  flex-grow: 0;
}

/* Header filter-bar: lives between brand and spacer. Collapsed at rest,
   grows to fill when scrolled. Directly beside the brand. */
.header-top-row > .filter-bar {
  flex: 0 1 0;
  min-width: 0;
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
  align-self: flex-end;
  flex-wrap: nowrap;
  transition:
    opacity 0.15s ease,
    flex-grow 0.18s cubic-bezier(0.2, 0.8, 0.2, 1),
    max-height 0.18s ease,
    margin-left 0.18s ease,
    padding 0.18s ease;
}

.site-header.scrolled .header-top-row > .filter-bar {
  flex-grow: 1;
  opacity: 1;
  max-height: 44px;
  margin-left: 20px;
  padding: 2px 24px;
  pointer-events: auto;
  overflow-x: auto;
  overflow-y: hidden;
  justify-content: flex-start;
  scrollbar-width: none;
  -ms-overflow-style: none;
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 24px,
    #000 calc(100% - 24px),
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 24px,
    #000 calc(100% - 24px),
    transparent 100%
  );
}

.header-top-row > .filter-bar::-webkit-scrollbar {
  display: none;
}

.header-top-row > .filter-bar .filter-pill {
  flex: none;
}

/* empty header filter-bar (no tags) → stays collapsed even when scrolled */
.header-top-row > .filter-bar:empty {
  flex-grow: 0 !important;
  max-height: 0 !important;
  margin-left: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
}

/* Nav: fades + collapses width on scroll. No margin-left: auto (spacer
   handles the right-alignment), so no non-transitionable snap. */
.nav {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 600px;
  overflow: hidden;
  white-space: nowrap;
  transition:
    opacity 0.15s ease,
    max-width 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.site-header.scrolled .nav {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
}

@media (max-width: 640px) {
  .header-inner {
    padding: 18px 14px 12px;
  }
  .site-header.scrolled .header-inner {
    padding-top: 8px;
    padding-bottom: 8px;
    /* tighter horizontal padding on scroll so the filter-bar can extend
       closer to the viewport edges */
    padding-left: 12px;
    padding-right: 12px;
  }
  .page {
    padding: 24px 18px 80px;
  }
  .header-top-row {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 20px;
  }

  /* Mobile scrolled: maximize filter-bar breathing room.
     Small margin from brand + smaller internal padding so pills get the
     full width between brand and the right edge. */
  .site-header.scrolled .header-top-row > .filter-bar {
    margin-left: 10px;
    padding: 2px 14px;
    mask-image: linear-gradient(
      to right,
      transparent 0,
      #000 14px,
      #000 calc(100% - 14px),
      transparent 100%
    );
    -webkit-mask-image: linear-gradient(
      to right,
      transparent 0,
      #000 14px,
      #000 calc(100% - 14px),
      transparent 100%
    );
  }
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4.6vw, 3.2rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
  display: inline-block;
  transform: rotate(-1.2deg);
  text-shadow: 0 2px 18px rgba(168, 153, 104, 0.12);
}

/* red hanko-style dot — the "." in neithan.rocks */
.brand-dot {
  color: var(--red);
  text-shadow: 0 0 12px var(--red-glow);
  font-weight: 500;
  margin: 0 0.02em;
}

.brand:hover {
  color: var(--gold-bright);
}
.brand:hover .brand-dot {
  color: #e35a5a;
}

.tagline {
  font-family: var(--font-label);
  font-weight: 300;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.24em;
  text-transform: lowercase;
  margin-top: 12px;
  /* no min-height — the &nbsp; in HTML holds the line until JS loads the
     real tagline, and the scrolled state can cleanly collapse to 0. */
}

@media (max-width: 640px) {
  .tagline {
    margin-top: 0;
  }
}

.nav {
  display: flex;
  gap: 28px;
  align-items: center;
}

.nav a {
  font-family: var(--font-label);
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  transition: color 0.2s ease;
  position: relative;
  padding-bottom: 4px;
}

.nav a:hover,
.nav a.active {
  color: var(--gold);
}

.nav a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--gold);
}

/* -------- Layout -------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

.layout-single {
  display: block;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .page {
    padding: 28px 18px 80px;
  }
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }
}

/* -------- Glass card -------- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
}

/* -------- Timeline / Posts -------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 56px;
}

.post {
  position: relative;
  padding: 32px 32px 36px;
  overflow: hidden; /* clip the kanji watermark */
  /* --accent-color drives kanji color AND (when featured) the glow.
     Default red for non-featured; overridden to gold on .featured;
     overridden further by inline style="--accent-color: #xxx" when
     the post has a tag. */
  --accent-color: var(--red);
}

.post.featured {
  --accent-color: var(--gold);
  border-color: color-mix(in srgb, var(--accent-color) 22%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent-color) 34%, transparent),
    0 0 40px -8px color-mix(in srgb, var(--accent-color) 32%, transparent),
    0 8px 32px rgba(0, 0, 0, 0.5);
}

/* kanji watermark sits BEHIND the post number + date for a stamped effect */
.post-kanji-watermark {
  position: absolute;
  top: 16px;
  left: 22px;
  font-family: var(--font-jp);
  font-weight: 300;
  font-size: clamp(3.8rem, 7vw, 5.6rem);
  line-height: 0.9;
  color: var(--accent-color);
  opacity: 0.1;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  letter-spacing: 0;
  white-space: nowrap;
}

.post.featured .post-kanji-watermark {
  opacity: 0.13;
}

/* all direct children sit above the watermark — except the badge,
   which needs to stay absolutely-positioned so the date below it
   doesn't get disrupted when the post is featured. */
.post > *:not(.post-kanji-watermark):not(.featured-badge) {
  position: relative;
  z-index: 1;
}

/* real-element FEATURED badge — absolute, top-right, above everything */
.featured-badge {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-label);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.34em;
  color: var(--accent-color);
  text-transform: none;
  text-shadow: 0 0 8px color-mix(in srgb, var(--accent-color) 28%, transparent);
}

.featured-badge .dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px var(--red-glow);
  flex: none;
}

.post-number {
  font-family: var(--font-jp);
  font-weight: 300;
  font-size: clamp(2.8rem, 5vw, 4rem);
  color: var(--text-dim);
  line-height: 1;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  display: inline-block;
  cursor: pointer; /* clickable to open dedicated post page */
}

/* small redundant kanji sitting beside the arabic number —
   color follows --accent-color, so it tracks tag color when present,
   and stays red (default) or gold (featured w/o tag) otherwise. */
.post-number-kanji {
  font-family: var(--font-jp);
  font-weight: 400;
  font-size: 0.36em;
  color: var(--accent-color);
  margin-left: 0.42em;
  display: inline-block;
  vertical-align: baseline;
  letter-spacing: 0;
  transform: translateY(-0.08em);
  opacity: 0.92;
}

.post-date {
  font-family: var(--font-label);
  font-size: 0.68rem;
  color: var(--text-faint);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  margin-bottom: 22px;
  font-weight: 400;
}

.post-media {
  margin: 22px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-deeper);
  border: 1px solid var(--border);
}

.post-media.grid {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border: none;
  background: transparent;
}

.post-media.grid .media-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-deeper);
  aspect-ratio: 1 / 1;
}

.post-media.grid .media-item img,
.post-media.grid .media-item video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* single-item (non-grid) keeps natural aspect ratio */
.post-media:not(.grid) img,
.post-media:not(.grid) video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: cover;
}

.post-text {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.75;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.post-text a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid var(--gold-glow);
}

.post-text a:hover {
  color: var(--gold-bright);
}

/* -------- Sidebar -------- */
.sidebar {
  position: sticky;
  top: 92px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-height: calc(100vh - 116px);
}

@media (max-width: 960px) {
  .sidebar {
    position: static;
    max-height: none;
  }
}

.sidebar-section {
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.sidebar-title {
  font-family: var(--font-label);
  font-weight: 500;
  font-size: 0.66rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.sidebar-title .accent {
  color: var(--gold);
}

.sidebar-scroll {
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}
.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

/* Tweets */
.tweet {
  padding: 14px 0;
  border-bottom: 1px dashed var(--border);
}

.tweet:last-child {
  border-bottom: none;
}

.tweet-text {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.tweet-time {
  font-family: var(--font-label);
  font-size: 0.64rem;
  color: var(--text-faint);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 8px;
}

/* Chat */
.chat-section {
  max-height: 44vh;
  flex: 0 1 auto;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

.chat-msg {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
  word-wrap: break-word;
}

.chat-msg.reply {
  margin-left: 18px;
  padding-left: 12px;
  border-left: 1px solid var(--border-strong);
}

.chat-user {
  color: var(--text-dim);
  font-weight: 600;
  margin-right: 8px;
}

.chat-user.admin {
  color: var(--gold);
}

.chat-time {
  font-family: var(--font-label);
  font-size: 0.62rem;
  color: var(--text-faint);
  margin-left: 6px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.chat-actions {
  margin-top: 4px;
  display: flex;
  gap: 10px;
  font-size: 0.7rem;
}

.chat-actions button {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0;
  font-family: var(--font-label);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.chat-actions button:hover {
  color: var(--gold);
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-form .row {
  display: flex;
  gap: 8px;
}

.chat-form .row input {
  flex: 1;
}

/* -------- Inputs -------- */
.input,
.textarea,
input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: border-color 0.2s ease, background 0.2s ease;
  resize: vertical;
}

.input:focus,
.textarea:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold-soft);
  background: rgba(255, 255, 255, 0.035);
}

.input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

/* -------- Buttons -------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(168, 153, 104, 0.08);
  border: 1px solid rgba(168, 153, 104, 0.35);
  color: var(--gold-bright);
  font-family: var(--font-label);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:hover {
  background: rgba(168, 153, 104, 0.14);
  border-color: var(--gold);
  box-shadow: 0 0 24px -6px var(--gold-glow);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: none;
}

.btn-danger {
  border-color: rgba(180, 80, 80, 0.35);
  color: #c98a8a;
  background: rgba(180, 80, 80, 0.06);
}

.btn-danger:hover {
  background: rgba(180, 80, 80, 0.14);
  border-color: rgba(180, 80, 80, 0.55);
  box-shadow: 0 0 24px -6px rgba(180, 80, 80, 0.25);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.68rem;
}

/* -------- Filter bar (home + featured) -------- */

.timeline-col {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0;
}

.filter-bar:empty {
  display: none;
}

.filter-pill {
  --flair-color: var(--gold);
  font-family: var(--font-label);
  font-size: 0.66rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-pill:hover {
  border-color: color-mix(in srgb, var(--flair-color) 45%, var(--border-strong));
  color: var(--text);
}

.filter-pill.active {
  background: color-mix(in srgb, var(--flair-color) 13%, transparent);
  border-color: color-mix(in srgb, var(--flair-color) 55%, transparent);
  color: var(--flair-color);
  box-shadow: 0 0 18px -2px color-mix(in srgb, var(--flair-color) 36%, transparent);
}

/* entrance: fade the whole bar in after tags load */
@media (prefers-reduced-motion: no-preference) {
  .filter-bar {
    animation: nrFadeIn 0.6s ease-out both 0.3s;
  }
}

/* content-placement version on the featured page: centered, with spacing */
.featured-filter-bar--content {
  justify-content: center;
  margin-bottom: 28px;
}

/* -------- Tag flairs (on posts) -------- */

.post-flairs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}

.flair {
  --flair-color: var(--gold);
  font-family: var(--font-label);
  font-size: 0.62rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--flair-color) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--flair-color) 42%, transparent);
  color: var(--flair-color);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* -------- Featured page -------- */
.featured-hero {
  text-align: center;
  margin-bottom: 56px;
}

.featured-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 5vw, 4rem);
  font-weight: 400;
  color: var(--text);
  transform: rotate(-1deg);
  display: inline-block;
  text-shadow: 0 2px 24px var(--gold-glow-soft);
}

.featured-hero p {
  color: var(--text-dim);
  margin-top: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 28px;
}

.featured-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  --accent-color: var(--gold);
  border-color: color-mix(in srgb, var(--accent-color) 22%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent-color) 34%, transparent),
    0 0 40px -8px color-mix(in srgb, var(--accent-color) 32%, transparent),
    0 8px 32px rgba(0, 0, 0, 0.5);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.4s ease;
  position: relative;
  overflow: hidden;
}

.featured-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent-color) 48%, transparent),
    0 0 60px -8px color-mix(in srgb, var(--accent-color) 38%, transparent),
    0 16px 48px rgba(0, 0, 0, 0.55);
}

.featured-card .post-number {
  font-size: clamp(2.2rem, 3.5vw, 2.8rem);
  color: var(--text-dim);
}

.featured-card .post-kanji-watermark {
  opacity: 0.1;
}

.featured-card > *:not(.post-kanji-watermark) {
  position: relative;
  z-index: 1;
}

/* -------- Dedicated post page -------- */

.post-page {
  max-width: 820px;
  margin: 0 auto;
}

.back-link {
  display: inline-block;
  font-family: var(--font-label);
  font-size: 0.7rem;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-bottom: 28px;
  padding: 6px 0;
  transition: color 0.2s ease;
}

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

.post.post-detail {
  padding: 40px 44px 48px;
}

.post.post-detail .post-number {
  cursor: default; /* already on this post — no navigation */
  font-size: clamp(3.4rem, 6vw, 4.6rem);
}

.post.post-detail .post-text {
  font-size: 1.04rem;
  line-height: 1.8;
  margin-top: 22px;
}

@media (max-width: 640px) {
  .post.post-detail { padding: 28px 22px 34px; }
}

.post-neighbors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 40px;
}

.post-neighbors .neighbor {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-dim);
  transition: all 0.2s ease;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.post-neighbors .neighbor:not(.disabled):hover {
  border-color: color-mix(in srgb, var(--gold) 40%, var(--border));
  color: var(--text);
  box-shadow: 0 0 24px -6px var(--gold-glow-soft);
}

.post-neighbors .neighbor:nth-child(2) {
  text-align: right;
}

.post-neighbors .neighbor.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.post-neighbors .dir {
  font-family: var(--font-label);
  font-size: 0.64rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.post-neighbors .num {
  font-family: var(--font-jp);
  font-weight: 300;
  font-size: 1.4rem;
  color: var(--text-dim);
  line-height: 1;
}

.post-neighbors .num .k {
  font-size: 0.55em;
  color: var(--red);
  margin-left: 0.42em;
  opacity: 0.85;
}

/* -------- Empty & loading states -------- */
.empty,
.loading {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-faint);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-family: var(--font-label);
  font-weight: 400;
}

/* -------- Utility -------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.display-font {
  font-family: var(--font-display);
  font-weight: 400;
}

/* ============================================================
   Lightbox — creative modal for media viewing
   ============================================================ */

.post-media img,
.post-media video {
  cursor: zoom-in;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox-overlay.open {
  display: block;
  opacity: 1;
}

/* big faint kanji watermark in the corner, matching post aesthetic */
.lightbox-overlay::before {
  content: attr(data-jp-num);
  position: fixed;
  top: 4vh;
  right: -2vw;
  font-family: var(--font-jp);
  font-weight: 300;
  font-size: clamp(14rem, 26vw, 24rem);
  line-height: 1;
  color: var(--gold);
  opacity: 0.04;
  pointer-events: none;
  user-select: none;
  letter-spacing: 0;
  white-space: nowrap;
}

.lightbox-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 92vw;
  max-height: 78vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-stage img,
.lightbox-stage video {
  max-width: 92vw;
  max-height: 78vh;
  display: block;
  border-radius: 10px;
  box-shadow: 0 30px 80px -10px rgba(0, 0, 0, 0.7),
              0 0 0 1px rgba(255, 255, 255, 0.06);
}

.lightbox-header {
  position: fixed;
  top: 28px;
  left: 32px;
  z-index: 2;
  pointer-events: none;
}

.lightbox-post-number {
  font-family: var(--font-jp);
  font-weight: 300;
  font-size: clamp(2.4rem, 4.5vw, 3.4rem);
  color: var(--text-dim);
  line-height: 1;
  letter-spacing: -0.01em;
}

.lightbox-post-number .lightbox-post-kanji {
  font-family: var(--font-jp);
  font-weight: 400;
  font-size: 0.36em;
  color: var(--red);
  margin-left: 0.42em;
  vertical-align: baseline;
  transform: translateY(-0.08em);
  display: inline-block;
}

.lightbox-post-date {
  font-family: var(--font-label);
  font-size: 0.66rem;
  color: var(--text-faint);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-top: 8px;
}

.lightbox-media-index {
  font-family: var(--font-label);
  font-size: 0.62rem;
  color: var(--text-faint);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-top: 6px;
}

.lightbox-close {
  position: fixed;
  top: 28px;
  right: 32px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  z-index: 3;
  font-family: var(--font-label);
}

.lightbox-close:hover {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 16px -4px var(--gold-glow);
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  z-index: 3;
}

.lightbox-nav.prev { left: 32px; }
.lightbox-nav.next { right: 32px; }

.lightbox-nav:hover {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 16px -4px var(--gold-glow);
}

.lightbox-nav[hidden] {
  display: none;
}

/* bottom drawer: post text, truncated by default, expands on click */
.lightbox-text-panel {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(720px, 92vw);
  padding: 16px 22px 14px;
  background: rgba(10, 10, 10, 0.82);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  border: 1px solid var(--border);
  border-radius: 14px;
  z-index: 2;
  box-shadow: 0 16px 48px -12px rgba(0, 0, 0, 0.6);
  max-height: 55vh;
  display: flex;
  flex-direction: column;
}

.lightbox-text-panel:empty {
  display: none;
}

.lightbox-text-content {
  font-family: var(--font-body);
  font-size: 0.94rem;
  color: var(--text);
  line-height: 1.75;
  max-height: 4.5em;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  white-space: pre-wrap;
  word-wrap: break-word;
  mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
}

.lightbox-text-content a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid var(--gold-glow-soft);
}

.lightbox-text-content.expanded {
  max-height: 46vh;
  overflow-y: auto;
  mask-image: none;
  -webkit-mask-image: none;
  padding-right: 8px;
}

.lightbox-text-content.expanded::-webkit-scrollbar { width: 4px; }
.lightbox-text-content.expanded::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

.lightbox-text-toggle {
  margin-top: 8px;
  align-self: flex-start;
  background: transparent;
  border: none;
  color: var(--gold);
  font-family: var(--font-label);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.2s ease;
}

.lightbox-text-toggle:hover {
  color: var(--gold-bright);
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .lightbox-header { top: 18px; left: 18px; }
  .lightbox-close { top: 18px; right: 18px; }
  .lightbox-nav.prev { left: 10px; }
  .lightbox-nav.next { right: 10px; }
  .lightbox-text-panel { bottom: 14px; }
}

/* ============================================================
   Entrance animations — subtle, premium. Honors reduced-motion.
   ============================================================ */

@media (prefers-reduced-motion: no-preference) {
  @keyframes nrFadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  @keyframes nrFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  @keyframes nrBrandIn {
    from { opacity: 0; transform: rotate(-1.2deg) scale(0.97); letter-spacing: 0.06em; }
    to   { opacity: 1; transform: rotate(-1.2deg) scale(1); letter-spacing: 0.02em; }
  }

  @keyframes nrNavIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  @keyframes nrSidebarIn {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
  }

  @keyframes nrKanjiFade {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 0.07; transform: scale(1); }
  }

  @keyframes nrKanjiFadeFeatured {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 0.11; transform: scale(1); }
  }

  .brand {
    animation: nrBrandIn 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both 0.05s;
  }

  .tagline {
    animation: nrFadeIn 0.8s ease-out both 0.45s;
  }

  .nav a {
    animation: nrNavIn 0.5s ease-out both;
  }
  .nav a:nth-child(1) { animation-delay: 0.18s; }
  .nav a:nth-child(2) { animation-delay: 0.26s; }
  .nav a:nth-child(3) { animation-delay: 0.34s; }
  .nav a:nth-child(4) { animation-delay: 0.42s; }

  .post,
  .featured-card {
    animation: nrFadeUp 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
  .post:nth-child(1), .featured-card:nth-child(1) { animation-delay: 0.1s; }
  .post:nth-child(2), .featured-card:nth-child(2) { animation-delay: 0.2s; }
  .post:nth-child(3), .featured-card:nth-child(3) { animation-delay: 0.3s; }
  .post:nth-child(4), .featured-card:nth-child(4) { animation-delay: 0.4s; }
  .post:nth-child(5), .featured-card:nth-child(5) { animation-delay: 0.5s; }
  .post:nth-child(n+6), .featured-card:nth-child(n+6) { animation-delay: 0.6s; }

  .post-kanji-watermark {
    animation: nrKanjiFade 1.5s ease-out both 0.4s;
  }
  .post.featured .post-kanji-watermark,
  .featured-card .post-kanji-watermark {
    animation-name: nrKanjiFadeFeatured;
  }

  .sidebar-section {
    animation: nrSidebarIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
  .sidebar-section:nth-of-type(1) { animation-delay: 0.25s; }
  .sidebar-section:nth-of-type(2) { animation-delay: 0.38s; }

  .featured-hero {
    animation: nrFadeUp 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both 0.05s;
  }
}
