/* ============================================================
   WAYFARER'S ALMANAC — design tokens
   A pressed-flower travel journal that hums with quiet magic.
   The page itself is a sky: pale morning blue at the header,
   drifting through dusk, settling into starlit night by the
   footer. Content sits on soft parchment panels above it.
   ============================================================ */

:root {
  --ink: #3e3a44;          /* primary text, warm charcoal-plum */
  --muted: #8b8578;        /* secondary text, warm taupe */
  --starlight: #f3efe2;    /* text used directly on the night sky */
  --sage: #7c9473;         /* primary accent — journeys, growing things */
  --sage-dim: #7c947322;
  --periwinkle: #8b9dc3;   /* secondary accent — quiet twilight magic */
  --peri-dim: #8b9dc322;
  --gold: #d9a24b;         /* tertiary accent — late afternoon light */
  --gold-dim: #d9a24b22;
  --cream: #fbf7ee;        /* card / panel surface */
  --border: #e4dcc8;
  --danger: #c96a5b;

  --font-display: "Cormorant Garamond", "Times New Roman", serif;
  --font-body: "Literata", Georgia, serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;

  --radius: 12px;
  --container: 980px;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  /* the sky: day at the top, dusk in the middle, night by the footer.
     percentages are relative to the full page height, so this scales
     naturally with however long a given page turns out to be. */
  background: linear-gradient(
    to bottom,
    #cfeaf7 0%,
    #dcebef 10%,
    #eaeae3 20%,
    #f3e4d8 32%,
    #e8c9c2 42%,
    #c9afc2 52%,
    #8e8eb8 64%,
    #4e4e86 76%,
    #232152 88%,
    #12102e 100%
  );
}

/* soft cloud blobs, both the fixed ones near the header and extra ones
   scattered down the page's daylight portion (positioned in JS) */
.sky-cloud,
.sky-cloud-extra {
  position: absolute;
  border-radius: 50%;
  background: #ffffff;
  filter: blur(20px);
  pointer-events: none;
  z-index: 0;
}

.sky-cloud { position: fixed; opacity: 0.45; }

.sky-decor,
.sky-stars {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  /* height is set in JS to the real document height — percentages here
     would resolve against body's auto height, which is unreliable */
}

.sky-star {
  position: absolute;
  border-radius: 50%;
  background: var(--starlight);
}

.sky-star.twinkle {
  animation: star-twinkle 5s ease-in-out infinite;
}

.sky-mote {
  position: absolute;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 5px rgba(217, 162, 75, 0.7);
  animation: mote-glow 4s ease-in-out infinite;
}

/* decorative marginalia — a vine-and-sigil motif climbing the margins,
   homepage only, hidden once the viewport is too narrow to have real
   margins to decorate */
.sky-vines {
  position: absolute;
  top: 0;
  width: 60px;
  pointer-events: none;
  z-index: 0;
  background-repeat: repeat-y;
  background-position: top center;
  background-size: 60px auto;
  display: none;
}

body.page-home .sky-vines { display: block; }

.sky-vines.left { left: 18px; }
.sky-vines.right { right: 18px; transform: scaleX(-1); }

/* the post-page equivalent — a dashed wayfarer's trail with waypost
   flags and a lantern sigil, instead of the homepage's living vine */
.sky-trail {
  position: absolute;
  top: 0;
  width: 60px;
  pointer-events: none;
  z-index: 0;
  background-repeat: repeat-y;
  background-position: top center;
  background-size: 60px auto;
  display: none;
}

body.page-post .sky-trail { display: block; }

.sky-trail.left { left: 18px; }
.sky-trail.right { right: 18px; transform: scaleX(-1); }

@media (max-width: 1300px) {
  .sky-vines, .sky-trail { display: none !important; }
}

@keyframes star-twinkle {
  0%, 100% { opacity: 0.18; }
  50% { opacity: 0.8; }
}

@keyframes mote-glow {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.55; }
}

a { color: var(--sage); text-decoration: none; }
a:hover { color: var(--periwinkle); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin: 0 0 0.5em;
}

.wrap { max-width: var(--container); margin: 0 auto; padding: 0 24px; width: 100%; position: relative; z-index: 2; }

/* ---------------- Header / nav ---------------- */
/* the header always sits at the very top of the page, so it's safe
   to assume it lands in the pale morning-sky zone regardless of how
   long the rest of the page runs. */

.site-header {
  position: relative;
  z-index: 2;
  padding: 36px 0 24px;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}

.brand:hover { color: var(--ink); }

.brand svg { width: 44px; height: 44px; flex-shrink: 0; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-text .name {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-text .tagline {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #5b5866;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}

.nav-links a { color: #5b5866; transition: color 0.15s ease; }
.nav-links a:hover, .nav-links a.active { color: var(--sage); }

.nav-links .pill {
  border: 1px solid rgba(62, 58, 68, 0.25);
  border-radius: 999px;
  padding: 8px 18px;
  color: #5b5866;
  background: rgba(255, 255, 255, 0.35);
}

.nav-links .pill:hover { border-color: var(--sage); color: var(--sage); }

/* ---------------- Wayfarer's mark (signature divider) ---------------- */

.rune-divider {
  display: block;
  width: 100%;
  max-width: 520px;
  margin: 48px auto;
  overflow: visible;
}

.rune-divider .trace {
  fill: none;
  stroke: rgba(62, 58, 68, 0.22);
  stroke-width: 1.2;
}

.rune-divider .node {
  fill: var(--periwinkle);
  opacity: 0.7;
}

.rune-divider .mark {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(217, 162, 75, 0.5));
}

/* small corner sigil used on cards */
.sigil {
  width: 22px;
  height: 22px;
  opacity: 0.55;
  color: var(--sage);
}

/* ---------------- Hero / featured post ---------------- */

main { flex: 1; position: relative; z-index: 1; }

.hero {
  padding: 64px 0 8px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2.6rem, 6vw, 3.8rem);
  color: var(--ink);
}

.hero p {
  font-family: var(--font-mono);
  color: #5b5866;
  font-size: 1rem;
  letter-spacing: 0.03em;
  max-width: 520px;
  margin: 0 auto;
}

/* content panels: cream parchment surfaces that float above the sky.
   text inside these is always legible, no matter where they land on
   the gradient behind them. */
.featured {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px;
  margin: 8px 0 56px;
  background: rgba(251, 247, 238, 0.92);
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 28px rgba(20, 15, 40, 0.08);
}

.featured .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.featured h2 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin-bottom: 14px;
}

.featured h2 a { color: inherit; }
.featured h2 a:hover { color: var(--sage); }

.featured .excerpt {
  color: var(--ink);
  opacity: 0.85;
  font-size: 1.15rem;
  margin-bottom: 20px;
}

.meta {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.tag-pill {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 11px;
  color: var(--sage);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  background: rgba(255, 255, 255, 0.4);
}

.tag-pill:hover { border-color: var(--sage); }

/* ---------------- Post grid ---------------- */
/* headings/labels that sit directly on the sky (not inside a card)
   need to read against both day and night, so they use the pale
   starlight color with a soft dark shadow for contrast up top too. */

.grid-heading {
  font-family: var(--font-mono);
  text-transform: lowercase;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
  margin: 0 0 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.grid-heading .label-chip {
  background: rgba(251, 247, 238, 0.9);
  border: 1px solid var(--border);
  backdrop-filter: blur(4px);
  color: var(--ink);
  padding: 5px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(20, 15, 40, 0.08);
}

.grid-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(217, 162, 75, 0.4);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 24px;
  margin-bottom: 28px;
}

.card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  background: rgba(251, 247, 238, 0.92);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 22px rgba(20, 15, 40, 0.07);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(20, 15, 40, 0.12);
}

.card .sigil { position: absolute; top: 18px; right: 18px; }

.card h3 { font-size: 1.35rem; margin: 0 10px 12px 0; padding-right: 26px; }
.card h3 a { color: var(--ink); }
.card h3 a:hover { color: var(--sage); }

.card .excerpt {
  color: var(--ink);
  opacity: 0.8;
  font-size: 1.02rem;
  margin-bottom: 16px;
}

.empty-state {
  text-align: center;
  padding: 32px 28px;
  color: var(--ink);
  font-family: var(--font-mono);
  max-width: 480px;
  margin: 0 auto;
  background: rgba(251, 247, 238, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(20, 15, 40, 0.07);
}

.empty-state a { color: var(--sage); }

/* ---------------- Pagination ---------------- */

.pagination {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin: 40px 0;
}

.pagination a, .pagination span {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  color: var(--ink);
  background: rgba(251, 247, 238, 0.85);
  backdrop-filter: blur(4px);
}

.pagination a:hover { border-color: var(--gold); color: var(--gold); }
.pagination .current { border-color: var(--sage); color: var(--sage); }

/* ---------------- Single post ---------------- */

.post-header { padding: 48px 0 0; }

.back-link {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: #5b5866;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
}

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

.post-header h1 { font-size: clamp(2.1rem, 4.6vw, 3rem); }

.draft-flag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--periwinkle);
  border-radius: 4px;
  padding: 3px 10px;
  margin-bottom: 16px;
}

/* the article itself is a parchment page laid over the sky, so it
   stays readable the whole way down regardless of how far into the
   night the scroll position has gone. */
.post-panel {
  background: rgba(251, 247, 238, 0.94);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(20, 15, 40, 0.08);
  padding: 8px 48px 48px;
  margin: 24px 0 60px;
}

@media (max-width: 640px) {
  .post-panel { padding: 8px 24px 32px; }
}

.post-body {
  padding: 12px 0 8px;
  font-size: 1.18rem;
}

.post-body h2 {
  font-size: 1.5rem;
  margin-top: 1.6em;
  padding-top: 0.2em;
  border-top: 1px solid var(--border);
}

.post-body h3 { font-size: 1.2rem; margin-top: 1.5em; color: var(--sage); }
.post-body p { margin: 0 0 1.2em; }
.post-body a { text-decoration: underline; text-decoration-color: var(--sage-dim); text-underline-offset: 3px; }

.post-body blockquote {
  margin: 1.6em 0;
  padding: 4px 22px;
  border-left: 3px solid var(--gold);
  color: var(--muted);
  font-style: italic;
}

.post-body pre {
  background: #f4efe2;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.post-body code {
  font-family: var(--font-mono);
  background: #f4efe2;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.88em;
  color: #8a6a2e;
}

.post-body pre code { background: none; padding: 0; color: var(--ink); }

.post-body ul, .post-body ol { padding-left: 1.4em; margin-bottom: 1.2em; }
.post-body img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.post-body hr { border: none; border-top: 1px solid var(--border); margin: 2.4em 0; }

/* ---------------- Footer ---------------- */
/* the footer always sits at the very bottom of the page, so it's
   safe to assume it lands in the night-sky zone. */

.site-footer {
  padding: 28px 0 40px;
  margin-top: 40px;
  position: relative;
  z-index: 2;
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.site-footer p {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--starlight);
  opacity: 0.85;
  margin: 0;
}

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

/* ---------------- Forms (admin) ---------------- */

.admin-shell { padding: 48px 0 80px; }

.admin-shell h1 { display: flex; align-items: center; gap: 12px; }

.login-card {
  max-width: 380px;
  margin: 80px auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  background: rgba(251, 247, 238, 0.94);
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 30px rgba(20, 15, 40, 0.1);
  text-align: center;
}

.login-card h1 { font-size: 1.5rem; }
.login-card p.sub {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 24px;
}

.field { margin-bottom: 18px; text-align: left; }

.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="date"],
.field textarea {
  width: 100%;
  background: #fffdf8;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
}

.field input:focus, .field textarea:focus {
  border-color: var(--sage);
  outline: none;
}

.field textarea { font-family: var(--font-mono); font-size: 0.92rem; resize: vertical; }
.field small { display: block; margin-top: 6px; color: var(--muted); font-size: 0.78rem; }

.field input[type="file"] {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row label { margin: 0; text-transform: none; font-size: 0.9rem; letter-spacing: normal; color: var(--ink); }

.btn {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  text-transform: lowercase;
  letter-spacing: 0.03em;
  border-radius: 6px;
  padding: 12px 24px;
  border: 1px solid var(--sage);
  background: var(--sage-dim);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn:hover { background: var(--sage); color: #fff; }
.btn.full { width: 100%; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn.ghost:hover { border-color: var(--sage); color: var(--sage); background: none; }
.btn.danger { border-color: var(--danger); background: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }

.error-msg {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--danger);
  margin-bottom: 16px;
}

.editor-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 28px;
}

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

.editor-grid textarea#content { min-height: 420px; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.admin-table th, .admin-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.live { background: var(--sage); box-shadow: 0 0 5px rgba(124, 148, 115, 0.6); }
.status-dot.draft { background: var(--gold); }

.row-actions { display: flex; gap: 10px; font-family: var(--font-mono); font-size: 0.76rem; }
.row-actions form { display: inline; }
.row-actions button {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-family: var(--font-mono); font-size: 0.76rem; padding: 0;
}
.row-actions button:hover { color: var(--danger); }
.row-actions a:hover { color: var(--sage); }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.admin-shell .top-bar h1,
.admin-shell .admin-table { color: var(--ink); }

.autosave-hint {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 20px;
}

.autosave-status {
  color: var(--sage);
  font-weight: 500;
}

/* admin content also floats on a parchment panel so it stays legible
   however long the table or form ends up being */
.admin-panel {
  background: rgba(251, 247, 238, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(20, 15, 40, 0.08);
  padding: 32px;
}

/* ---------------- 404 ---------------- */

.not-found {
  text-align: center;
  max-width: 420px;
  margin: 80px auto;
  padding: 48px 32px;
  color: var(--ink);
  background: rgba(251, 247, 238, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(20, 15, 40, 0.1);
}

.not-found-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 8px;
}

.not-found h1 { font-size: 2.6rem; color: var(--ink); margin-bottom: 18px; }
.not-found p { font-family: var(--font-body); color: var(--ink); opacity: 0.82; font-size: 1.03rem; line-height: 1.7; }
.not-found a { color: var(--sage); font-family: var(--font-mono); font-size: 0.85rem; }
