/* ============================================================================
   AFTERGOD — public theme
   Direction: warm gilded decay (the dead gods) meets cold machine precision
   (the Continuum). Liturgical display type + monospace "machine annotation".
   All colours/fonts are var()-driven so the admin Settings panel can retheme.
   ========================================================================== */

:root {
  /* Palette — overridable from Settings via inline :root in the layout */
  --bg:            #0c0a09;
  --bg-2:          #14100c;
  --surface:       #1b1611;
  --surface-2:     #241d16;
  --ink:           #ece3d0;
  --ink-dim:       #a89a80;
  --ink-faint:     #6f6553;
  --brass:         #c79a45;
  --brass-bright:  #e6c169;
  --ember:         #b23a29;
  --ember-bright:  #d6503b;
  --verdigris:     #3f8f7d;
  --verdigris-bright: #5fbfa6;

  --rule:          rgba(199, 154, 69, 0.28);
  --rule-faint:    rgba(199, 154, 69, 0.14);

  /* Type */
  --font-display: 'Cinzel', 'Trajan Pro', 'Times New Roman', serif;
  --font-body:    'EB Garamond', 'Georgia', 'Times New Roman', serif;
  --font-mono:    'Spline Sans Mono', 'JetBrains Mono', ui-monospace, 'Courier New', monospace;

  --wrap: 1140px;
  --wrap-narrow: 760px;
  --radius: 2px;
  --shadow: 0 18px 50px -20px rgba(0,0,0,0.8);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@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; }
}
body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 50% -10%, rgba(199,154,69,0.06), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(63,143,125,0.05), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.7;
  font-feature-settings: "liga" 1, "kern" 1, "onum" 1;
  min-height: 100vh;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--brass-bright); text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--ember-bright); }
::selection { background: var(--ember); color: #fff; }

/* ---------- Type scale ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin: 0 0 .6em;
}
h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); letter-spacing: .02em; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.7rem); }
h3 { font-size: clamp(1.3rem, 2.2vw, 1.7rem); }
p { margin: 0 0 1.1em; }
strong { color: #f6efdd; }
blockquote {
  margin: 1.6em 0; padding: .2em 0 .2em 1.4em;
  border-left: 2px solid var(--brass);
  color: var(--ink-dim); font-style: italic; font-size: 1.15em;
}
hr { border: 0; height: 1px; background: var(--rule); margin: 2.4em 0; }
code, kbd { font-family: var(--font-mono); font-size: .9em; color: var(--verdigris-bright); }

/* Eyebrow — the Continuum "annotating" the page */
.eyebrow {
  font-family: var(--font-mono);
  font-size: .74rem; letter-spacing: .28em; text-transform: uppercase;
  color: var(--verdigris-bright);
  display: inline-flex; align-items: center; gap: .6em;
  margin: 0 0 1.1em;
}
.eyebrow::before { content: "§"; color: var(--brass); font-size: 1.1em; }

/* ---------- Layout primitives ---------- */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 1.5rem; }
.wrap--narrow { max-width: var(--wrap-narrow); }
.section { padding-block: clamp(3.5rem, 8vw, 6.5rem); }
.section--tight { padding-block: clamp(2.5rem, 5vw, 4rem); }
.center { text-align: center; }
.stack > * + * { margin-top: 1.1rem; }

/* Ornamental divider: double rule + central engine glyph */
.divider { display: flex; align-items: center; gap: 1rem; color: var(--brass); margin: 0 auto; max-width: 460px; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: linear-gradient(90deg, transparent, var(--rule) 30%, var(--rule)); }
.divider::after { transform: scaleX(-1); }
.divider__mark { font-family: var(--font-display); font-size: 1.1rem; letter-spacing: .3em; color: var(--brass); }

/* ---------- Header / nav ---------- */
.masthead {
  position: sticky; top: 0; z-index: 50;
  background: rgba(12,10,9,0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule-faint);
}
.masthead__inner { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding-block: .9rem; }
.brand { display: inline-flex; align-items: center; gap: .7rem; font-family: var(--font-display); font-size: 1.4rem; letter-spacing: .22em; text-transform: uppercase; color: var(--ink); }
.brand:hover { color: var(--brass-bright); }
.brand img { height: 38px; width: auto; }
.brand__mark { width: 30px; height: 30px; color: var(--brass); }

.nav { display: flex; align-items: center; gap: 1.6rem; }
.nav a {
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-dim); position: relative; padding-block: .4rem;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav a::after { content: ""; position: absolute; left: 0; right: 100%; bottom: 0; height: 1px; background: var(--brass); transition: right .25s ease; }
.nav a:hover::after, .nav a[aria-current="page"]::after { right: 0; }

.nav-toggle { display: none; background: none; border: 1px solid var(--rule); color: var(--ink); width: 44px; height: 44px; border-radius: var(--radius); cursor: pointer; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav {
    position: fixed; inset: 64px 0 auto 0; flex-direction: column; gap: 0; align-items: stretch;
    background: var(--bg-2); border-bottom: 1px solid var(--rule);
    padding: 1rem 1.5rem 1.5rem; transform: translateY(-120%); transition: transform .3s ease; box-shadow: var(--shadow);
  }
  .nav[data-open="true"] { transform: translateY(0); }
  .nav a { padding-block: .85rem; border-bottom: 1px solid var(--rule-faint); }
  .nav a::after { display: none; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .6rem;
  font-family: var(--font-mono); font-size: .8rem; letter-spacing: .16em; text-transform: uppercase;
  padding: .95rem 1.7rem; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--brass); color: var(--brass-bright); background: transparent;
  transition: all .22s ease; text-align: center;
}
.btn:hover { background: var(--brass); color: #17120a; box-shadow: 0 0 24px -6px var(--brass); }
.btn--primary { background: var(--ember); border-color: var(--ember); color: #fbeee9; }
.btn--primary:hover { background: var(--ember-bright); border-color: var(--ember-bright); color: #fff; box-shadow: 0 0 26px -6px var(--ember); }
.btn--ghost { border-color: var(--rule); color: var(--ink-dim); }
.btn--ghost:hover { border-color: var(--ink-dim); color: var(--ink); background: transparent; box-shadow: none; }
.btn--block { width: 100%; justify-content: center; }
.btn--sm { padding: .6rem 1.1rem; font-size: .72rem; }

/* ---------- Hero ---------- */
.hero { position: relative; padding-block: clamp(4.5rem, 12vw, 9rem); overflow: hidden; text-align: center; }
.hero__engine {
  position: absolute; top: 50%; left: 50%; width: min(900px, 130vw); height: min(900px, 130vw);
  transform: translate(-50%, -50%); color: var(--brass); opacity: .09; pointer-events: none; z-index: 0;
  animation: rotate 220s linear infinite;
}
.hero__engine--counter { animation-direction: reverse; animation-duration: 300s; width: min(620px, 90vw); height: min(620px, 90vw); opacity: .07; color: var(--verdigris); }
@keyframes rotate { to { transform: translate(-50%, -50%) rotate(360deg); } }
.hero > .wrap { position: relative; z-index: 1; }
.hero h1 { text-shadow: 0 2px 30px rgba(0,0,0,.6); }
.hero__lede { font-size: 1.3rem; color: var(--ink-dim); max-width: 40ch; margin: 0 auto 2rem; }
.hero__actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* Drop cap for lore prose */
.dropcap::first-letter {
  font-family: var(--font-display); float: left; font-size: 4.2rem; line-height: .82;
  padding: .05em .12em 0 0; color: var(--ember); font-weight: 700;
}

/* ---------- Cards ---------- */
.grid { display: grid; gap: 1.6rem; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid--3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .grid--3, .grid--2 { grid-template-columns: 1fr; } }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--rule-faint);
  border-radius: var(--radius); padding: 1.6rem; transition: border-color .25s ease, transform .25s ease;
  display: flex; flex-direction: column;
}
.card:hover { border-color: var(--rule); transform: translateY(-3px); }
/* Manuscript / machine-panel corner brackets */
.card::before, .card::after {
  content: ""; position: absolute; width: 14px; height: 14px; border: 1px solid var(--brass); opacity: .55;
}
.card::before { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.card::after { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }
.card__media { margin: -1.6rem -1.6rem 1.2rem; border-bottom: 1px solid var(--rule-faint); overflow: hidden; }
.card__media img { width: 100%; aspect-ratio: 16/10; object-fit: cover; transition: transform .4s ease; }
.card:hover .card__media img { transform: scale(1.04); }
.card__title { font-size: 1.3rem; margin-bottom: .4rem; }
.card__meta { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--verdigris); margin-bottom: .7rem; }
.card__excerpt { color: var(--ink-dim); font-size: 1rem; margin-bottom: 1.1rem; }
.card__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* ---------- Prose (page / post body from WYSIWYG) ---------- */
.prose { font-size: 1.16rem; }
.prose > * { max-width: 68ch; }
.prose img { border-radius: var(--radius); border: 1px solid var(--rule-faint); margin: 1.8em 0; max-width: 100%; }
.prose img.align-left { float: left; margin: .4em 1.6em 1em 0; max-width: 46%; }
.prose img.align-right { float: right; margin: .4em 0 1em 1.6em; max-width: 46%; }
.prose img.align-center { margin-inline: auto; }
.prose h2, .prose h3 { margin-top: 1.6em; }
.prose h2::before { content: "§ "; color: var(--brass); font-family: var(--font-mono); font-size: .7em; vertical-align: middle; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.prose li { margin-bottom: .4em; }
.prose a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); }
.prose table { width: 100%; border-collapse: collapse; margin: 1.6em 0; font-size: .98rem; }
.prose th, .prose td { border: 1px solid var(--rule-faint); padding: .6em .8em; text-align: left; }
.prose th { background: var(--surface-2); font-family: var(--font-mono); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--brass); }
.prose figure { margin: 1.8em 0; }
.prose figcaption { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-faint); text-align: center; margin-top: .6em; }

/* ---------- Page header band ---------- */
.page-head { position: relative; padding-block: clamp(3rem, 7vw, 5rem); border-bottom: 1px solid var(--rule-faint); text-align: center; }
.page-head__meta { font-family: var(--font-mono); font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; color: var(--verdigris); }

/* ---------- Store ---------- */
.product-hero { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 3rem; align-items: start; }
@media (max-width: 820px) { .product-hero { grid-template-columns: 1fr; gap: 2rem; } }
.product-cover { border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
.price { font-family: var(--font-display); font-size: 2.4rem; color: var(--brass-bright); }
.price--free { color: var(--verdigris-bright); }
.badge { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; padding: .25em .7em; border: 1px solid var(--rule); border-radius: 999px; color: var(--brass); }
.badge--featured { color: var(--ember-bright); border-color: var(--ember); }

/* ---------- Cart ---------- */
.cart-row { display: flex; align-items: center; gap: 1.2rem; padding: 1.1rem 0; border-bottom: 1px solid var(--rule-faint); }
.cart-row__title { font-family: var(--font-display); font-size: 1.15rem; }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 1.4rem; font-family: var(--font-display); font-size: 1.5rem; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-family: var(--font-mono); font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: .45rem; }
.input, .textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--rule); color: var(--ink);
  padding: .85rem 1rem; border-radius: var(--radius); font-family: var(--font-body); font-size: 1.05rem;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(199,154,69,.15); }
.textarea { min-height: 140px; resize: vertical; }

/* ---------- Newsletter band ---------- */
.enlist { background: linear-gradient(180deg, var(--surface), var(--bg-2)); border-block: 1px solid var(--rule-faint); }
.enlist__form { display: flex; gap: .8rem; max-width: 520px; margin: 1.4rem auto 0; }
.enlist__form .input { flex: 1; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 560px) { .enlist__form { flex-direction: column; } }

/* ---------- Flash / alerts ---------- */
.alert { border: 1px solid var(--rule); border-left-width: 3px; border-radius: var(--radius); padding: .9rem 1.2rem; margin-bottom: 1.4rem; font-size: 1rem; background: var(--surface); }
.alert--success { border-left-color: var(--verdigris); color: var(--verdigris-bright); }
.alert--error { border-left-color: var(--ember); color: var(--ember-bright); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--rule-faint); background: var(--bg-2); padding-block: 3rem 2rem; margin-top: 2rem; }
.footer__grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 2rem; margin-bottom: 2rem; }
@media (max-width: 720px) { .footer__grid { grid-template-columns: 1fr; gap: 1.6rem; } }
.footer h4 { font-family: var(--font-mono); font-size: .76rem; letter-spacing: .18em; text-transform: uppercase; color: var(--brass); }
.footer a { color: var(--ink-dim); display: block; padding: .25rem 0; font-size: 1rem; }
.footer a:hover { color: var(--ink); }
.footer__blurb { color: var(--ink-faint); font-size: 1rem; max-width: 34ch; }
.footer__base { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 1.4rem; border-top: 1px solid var(--rule-faint); font-family: var(--font-mono); font-size: .74rem; letter-spacing: .1em; color: var(--ink-faint); }
.social { display: flex; gap: 1rem; }
.social a { width: 22px; height: 22px; color: var(--ink-dim); }
.social a:hover { color: var(--brass); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: .4rem; justify-content: center; list-style: none; padding: 0; margin: 2.5rem 0 0; font-family: var(--font-mono); font-size: .82rem; }
.pagination a, .pagination span { display: inline-flex; min-width: 40px; height: 40px; align-items: center; justify-content: center; padding: 0 .5rem; border: 1px solid var(--rule-faint); border-radius: var(--radius); color: var(--ink-dim); }
.pagination a:hover { border-color: var(--brass); color: var(--brass-bright); }
.pagination .active span { background: var(--brass); color: #17120a; border-color: var(--brass); }
.pagination .disabled span { opacity: .35; }

/* ---------- Utilities ---------- */
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.mono { font-family: var(--font-mono); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.reveal { animation: rise .7s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
:focus-visible { outline: 2px solid var(--verdigris-bright); outline-offset: 3px; }
