:root {
  --bg: #121212;
  --text: #e0e0e0;
  --muted: #a8a8a8;
  --gold: #c5a059;
  --green: #3d4b3a;
  --card: #f2ead9;
  --card-text: #1a1a1a;
  --border: rgba(197, 160, 89, 0.35);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

h1,
h2,
h3,
.site-title,
.card-title,
.hero-title {
  font-family: "Playfair Display", "Times New Roman", serif;
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, rgba(18, 18, 18, 0.95), rgba(18, 18, 18, 0.75));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  /* Avoid backdrop-filter on the header flattening one corner of nested rounded images (Chrome). */
  isolation: isolate;
}

.brand:hover {
  text-decoration: none;
}

.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand-text {
  font-family: "Playfair Display", serif;
  letter-spacing: 0.12em;
  font-size: 0.95rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  color: var(--text);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav a:hover {
  color: var(--gold);
  text-decoration: none;
}

.nav-icon {
  display: inline-flex;
  width: 1.25rem;
  height: 1.25rem;
  opacity: 0.85;
}

/* Hero */
.hero {
  position: relative;
  min-height: min(70vh, 560px);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 3rem 1rem 4rem;
  background: #0a0a0a;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.55) contrast(1.05);
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(18, 18, 18, 0.2) 0%,
    rgba(18, 18, 18, 0.75) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 720px;
}

.hero-title {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 5vw, 3.25rem);
  letter-spacing: 0.18em;
  color: var(--gold);
  text-transform: uppercase;
}

.hero-sub {
  margin: 0 0 1.75rem;
  color: var(--text);
  font-size: 1.05rem;
}

.btn-outline {
  display: inline-block;
  padding: 0.65rem 1.75rem;
  border: 1px solid var(--gold);
  color: var(--gold);
  background: transparent;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}

.btn-outline:hover {
  background: rgba(197, 160, 89, 0.12);
  text-decoration: none;
}

.vegvisir-wrap {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

.vegvisir {
  width: 56px;
  height: 56px;
  opacity: 0.9;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  padding: 2.5rem 0 4rem;
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

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

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

.card {
  background: var(--card);
  color: var(--card-text);
  border: 3px solid #e8dfc8;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.card-img {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 1rem 1.1rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-title {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  color: #222;
}

.card-pubdate {
  margin: 0;
  font-size: 0.75rem;
  color: #666;
  text-align: center;
  letter-spacing: 0.04em;
}

.card-pubdate time {
  font-variant-numeric: tabular-nums;
}

.card-actions {
  margin-top: auto;
  display: flex;
  justify-content: center;
}

.btn-dark {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: #1e1e1e;
  color: var(--text);
  border: 1px solid #333;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
}

.btn-dark:hover {
  border-color: var(--gold);
  color: var(--gold);
  text-decoration: none;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.widget {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem;
}

.widget-title {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.rune-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}

.rune-char {
  text-align: center;
  font-size: 3rem;
  line-height: 1;
  color: #fff;
  font-family: "Playfair Display", serif;
}

.rune-foot {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.top-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.top-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.65rem;
  align-items: start;
}

.top-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.top-item a {
  color: var(--text);
  font-size: 0.88rem;
}

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

.top-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.top-pubdate {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.1rem;
  font-variant-numeric: tabular-nums;
}

/* Article detail */
.article-hero {
  position: relative;
  min-height: 280px;
  background: #0a0a0a;
}

.article-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
  filter: brightness(0.55);
}

.article-hero .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(18, 18, 18, 0.95));
}

.article-hero .inner {
  position: relative;
  z-index: 2;
  padding: 4rem 1rem 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.article-hero h1 {
  margin: 0;
  color: var(--gold);
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.article-pubdate {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.article-pubdate time {
  font-variant-numeric: tabular-nums;
}

.article-meta {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.prose {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.prose :where(h2, h3) {
  color: var(--gold);
  font-family: "Playfair Display", serif;
}

.prose :where(p, li) {
  color: var(--text);
}

.prose img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
}

.prose pre {
  background: #1a1a1a;
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid #333;
}

.prose-article {
  padding-bottom: 1.5rem;
}

.article-engagement {
  max-width: 720px;
  margin: 0 auto 1rem;
  padding: 0 1rem;
}

.article-engagement-inner {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.article-stat-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.article-stat-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
}

.article-stat-value {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.article-like-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-like {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  background: #1e1e1e;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 2px;
}

.btn-like:hover:not(:disabled) {
  background: rgba(197, 160, 89, 0.12);
}

.btn-like:disabled {
  opacity: 0.75;
  cursor: default;
  border-color: #555;
  color: var(--muted);
}

.btn-like-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.like-count-wrap {
  font-size: 0.9rem;
  color: var(--muted);
}

.like-count-num {
  color: var(--gold);
  margin-left: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.like-count-label {
  font-size: 0.8rem;
}

/* Kodex static page */
.kodex-page {
  padding: 2.5rem 1rem 4rem;
  max-width: 800px;
  margin: 0 auto;
}

.kodex-page-title {
  margin: 0 0 1.75rem;
  font-family: "Playfair Display", serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  text-align: center;
}

.kodex-prose {
  margin: 0;
  padding: 0;
  max-width: none;
}

.kodex-back {
  text-align: center;
  margin-top: 2.5rem;
}

/* Footer minimal */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Admin */
.admin-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.admin-wrap h1 {
  font-family: "Playfair Display", serif;
  color: var(--gold);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #333;
  padding: 0.65rem 0.5rem;
  text-align: left;
}

.admin-table th {
  color: var(--muted);
  font-weight: 500;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-form label {
  display: block;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-form input[type="text"],
.admin-form textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  background: #1a1a1a;
  border: 1px solid #333;
  color: var(--text);
  font-family: inherit;
}

.admin-form textarea {
  min-height: 220px;
}

.admin-form .row {
  margin-top: 0.75rem;
}

.error {
  color: #e88;
  margin-bottom: 1rem;
}

.mobile-nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}

@media (max-width: 640px) {
  .mobile-nav-toggle {
    display: inline-block;
  }

  .nav.collapsible {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-end;
  }

  .nav.collapsible.open {
    display: flex;
  }

  .header-inner {
    flex-wrap: wrap;
  }
}
