:root {
  color-scheme: light;
  --bg: #f4efe7;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-border: rgba(44, 32, 24, 0.1);
  --text: #1f1a17;
  --muted: #6a625c;
  --accent: #5a3d2b;
  --accent-2: #9e6a49;
  --shadow: 0 18px 50px rgba(34, 22, 15, 0.12);
  --gradient-top: #faf6f1;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1614;
  --panel: rgba(30, 26, 23, 0.85);
  --panel-border: rgba(244, 239, 231, 0.1);
  --text: #e6dfd5;
  --muted: #a69e97;
  --accent: #d4a373;
  --accent-2: #e2b49a;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  --gradient-top: #241f1c;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.65;
  background:
    radial-gradient(circle at top left, rgba(158, 106, 73, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(90, 61, 43, 0.12), transparent 28%),
    linear-gradient(180deg, var(--gradient-top) 0%, var(--bg) 100%);
  background-attachment: fixed;
  transition: background 0.3s ease, color 0.3s ease;
}

.logo-img {
  filter: invert(1);
  transition: filter 0.3s ease;
}

[data-theme="dark"] .logo-img {
  filter: invert(0);
}

.theme-toggle {
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
  box-shadow: var(--shadow);
}

a {
  color: inherit;
}

button {
  font: inherit;
}

.site-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-header {
  padding: 3rem 0 1rem;
}

.site-title {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 4.25rem);
  letter-spacing: -0.03em;
  line-height: 1.02;
}

.eyebrow {
  margin: 0 0 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
  color: var(--accent-2);
}

.site-tagline {
  margin: 0.75rem 0 0;
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.06rem;
}

.site-main {
  padding: 1rem 0 3rem;
}

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

.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.status,
.error,
.empty-state {
  padding: 1rem 1.1rem;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.status strong {
  color: var(--accent);
}

.error {
  border-color: rgba(138, 34, 34, 0.22);
  color: #7d2020;
}

.category-group {
  margin: 2rem 0 2.5rem;
  padding: 1.2rem 1.2rem 1rem;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.category-title {
  margin: 0 0 0.85rem;
  font-size: 1.45rem;
}

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

.story-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.6rem 0;
  border-top: 1px solid rgba(44, 32, 24, 0.08);
}

.story-item:first-child {
  border-top: 0;
}

.story-link,
.category-link,
.back-link {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
}

.story-link {
  font-size: 1.06rem;
  font-weight: 700;
}

.story-link:hover,
.category-link:hover,
.back-link:hover {
  text-decoration: underline;
}

.story-meta {
  color: var(--muted);
  font-size: 0.94rem;
}

.article-view {
  margin-top: 1.25rem;
  padding: 1.35rem 1.35rem 1.6rem;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.article-view h2 {
  margin-top: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.08;
}

.article-body {
  max-width: 72ch;
}

.article-body img {
  max-width: 100%;
  height: auto;
}

.article-body pre {
  overflow: auto;
  padding: 1rem;
  border-radius: 16px;
  background: rgba(18, 13, 10, 0.92);
  color: #f7efe9;
}

.article-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
}

.article-body blockquote {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 4px solid rgba(90, 61, 43, 0.35);
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.brand-link {
  display: inline-flex;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.25rem;
  margin: 0 0 1.5rem;
  font-size: 0.92rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.site-nav a {
  text-decoration: none;
  color: var(--muted);
  padding-bottom: 0.3rem;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

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

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

/* Homepage hero */
.hero {
  display: flex;
  gap: 2rem;
  align-items: center;
  margin: 0 0 2rem;
}

.hero-mascot {
  flex: 0 0 auto;
  width: clamp(96px, 18vw, 160px);
  opacity: 0.92;
}

.hero-text {
  flex: 1 1 auto;
  max-width: 60ch;
}

.hero-text p {
  margin: 0 0 0.85rem;
}

.hero-text p:last-child {
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .hero {
    flex-direction: column;
    text-align: center;
  }
}

/* "Right now" card */
.now-card .category-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.now-date {
  font-size: 0.78rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

.now-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.now-grid li {
  padding: 0.1rem 0;
}

.now-label {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  margin-bottom: 0.2rem;
}

/* Recent updates list */
.updates-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.update-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.55rem 0;
  border-top: 1px solid rgba(44, 32, 24, 0.08);
}

.update-item:first-child {
  border-top: 0;
}

.update-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  color: var(--accent);
}

.update-tag-diary {
  color: var(--accent-2);
}

.update-link {
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
}

.update-link:hover {
  text-decoration: underline;
}

.update-date {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Explore cards (writings / diary entry points) */
.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.explore-card {
  display: flex;
  flex-direction: column;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.explore-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
}

.explore-card p {
  margin: 0 0 1rem;
  color: var(--muted);
  flex-grow: 1;
}

.explore-card a {
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
}

.explore-card a:hover {
  text-decoration: underline;
}

/* Button badges */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 2rem 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 88px;
  height: 31px;
  padding: 0 0.3rem;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-align: center;
  text-transform: uppercase;
  text-decoration: none;
}

.badge img {
  height: 22px;
  width: auto;
}

/* Diary */
.diary-entry {
  position: relative;
  margin: 0 0 1.75rem;
  padding: 1.3rem 1.3rem 1.5rem 1.6rem;
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--accent-2);
  border-radius: 18px;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 2.1rem,
      rgba(44, 32, 24, 0.05) 2.1rem,
      rgba(44, 32, 24, 0.05) calc(2.1rem + 1px)
    ),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.diary-date {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.diary-title {
  margin: 0.25rem 0 0.4rem;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
}

.diary-title a {
  text-decoration: none;
  color: inherit;
}

.diary-title a:hover {
  text-decoration: underline;
}

.diary-mood {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--accent-2);
}

.diary-body {
  max-width: 68ch;
}

/* Easter egg toast */
.easter-egg-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 20px);
  max-width: min(90vw, 420px);
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  font-size: 0.92rem;
  text-align: center;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 100;
}

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

/* Marquee banner */
.marquee-wrap {
  overflow: hidden;
  margin: 0 0 1.75rem;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.marquee {
  display: flex;
  width: max-content;
  gap: 3rem;
  padding: 0.6rem 0;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
  animation: marquee-scroll 26s linear infinite;
}

.marquee-wrap:hover .marquee {
  animation-play-state: paused;
}

.marquee span {
  flex: 0 0 auto;
}

@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .marquee {
    animation: none;
  }
}

/* Sparkle trail */
.sparkle {
  position: fixed;
  top: 0;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  pointer-events: none;
  z-index: 999;
  opacity: 0.85;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

/* About page: fact list + topic pills */
.fact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.fact-list li {
  padding-left: 1.6rem;
  position: relative;
}

.fact-list li::before {
  content: "*";
  position: absolute;
  left: 0;
  color: var(--accent-2);
  font-weight: 700;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.82rem;
  color: var(--accent);
}

.colophon {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--panel-border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Shrine page */
.shrine-card {
  margin: 0 0 1.75rem;
  padding: 1.4rem 1.4rem 1.6rem;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.shrine-card h2 {
  margin-top: 0;
}

.shrine-card.linux-corner {
  display: flex;
  gap: 1.75rem;
  align-items: center;
}

.linux-mascot {
  flex: 0 0 auto;
  width: clamp(140px, 26vw, 240px);
}

.linux-text {
  flex: 1 1 auto;
}

.terminal {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: rgba(18, 13, 10, 0.92);
  color: #c9f7c5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.6;
  overflow-x: auto;
}

.terminal .prompt {
  color: #7fd3ff;
}

@media (max-width: 640px) {
  .shrine-card.linux-corner {
    flex-direction: column;
    text-align: center;
  }
}

/* Links page */
.sitemap-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sitemap-list li {
  padding: 0.6rem 0;
  border-top: 1px solid rgba(44, 32, 24, 0.08);
}

.sitemap-list li:first-child {
  border-top: 0;
}

.sitemap-list a {
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
}

.sitemap-list a:hover {
  text-decoration: underline;
}

.sitemap-list p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.webring-badge {
  margin-top: 1rem;
  padding: 1.1rem 1.2rem;
  border: 2px dashed var(--panel-border);
  border-radius: 18px;
  text-align: center;
  color: var(--muted);
}

/* Extras / toys */
.toy-card {
  margin: 0 0 1.75rem;
}

.toy-button {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: var(--accent);
  color: var(--gradient-top);
  padding: 0.6rem 1.2rem;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.toy-button:hover {
  filter: brightness(1.08);
}

.toy-output {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  min-height: 1.5em;
  font-style: italic;
}

.toy-input {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

/* Memes - masonry gallery */
.meme-grid {
  column-count: 1;
  column-gap: 1rem;
}

@media (min-width: 540px) {
  .meme-grid { column-count: 2; }
}

@media (min-width: 880px) {
  .meme-grid { column-count: 3; }
}

@media (min-width: 1200px) {
  .meme-grid { column-count: 4; }
}

.meme-item {
  margin: 0 0 1rem;
  break-inside: avoid;
}

.meme-item img {
  display: block;
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

/* 404 / secret page */
.lost-page {
  text-align: center;
  padding: 3rem 1rem;
}

.lost-page .hero-mascot {
  width: clamp(120px, 24vw, 200px);
  margin: 0 auto 1.5rem;
}

.lost-page h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  margin: 0 0 0.5rem;
}

.lost-page p {
  color: var(--muted);
  max-width: 50ch;
  margin: 0 auto 1.5rem;
}

@media (max-width: 640px) {
  .site-header {
    padding-top: 2rem;
  }

  .category-group,
  .article-view,
  .diary-entry,
  .shrine-card {
    padding: 1rem;
    border-radius: 18px;
  }

  .update-date {
    margin-left: 0;
  }
}
