/* Written Legacy Publishing
   --------------------------------------------------------------
   Brand colours arrive as CSS custom properties injected from the
   settings table, so changing --brand in admin restyles the site.
   Fallbacks below keep the stylesheet usable on its own.          */

:root {
  --brand: #490066;
  --accent: #B28500;
  --brand-dark: #2E0040;

  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e2e5e9;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --ok: #2d6b2d;
  --err: #9b2c2c;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .12);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.center { text-align: center; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(28px, 4vw, 42px); font-family: var(--serif); }
h2 { font-size: clamp(22px, 3vw, 30px); font-family: var(--serif); }
h3 { font-size: 19px; }

/* ── Header ─────────────────────────────────────────────── */

.site-head {
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}
.head-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; min-height: 82px; flex-wrap: wrap; padding: 10px 0;
}
.brand { display: flex; align-items: center; }
.brand img { max-height: 62px; width: auto; }
.brand-text {
  font-family: var(--serif); font-size: 20px; font-weight: 700;
  color: var(--brand); letter-spacing: .2px;
}
.brand:hover { text-decoration: none; }

.site-nav { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.site-nav a { color: var(--ink); font-size: 15px; }
.site-nav a:hover { color: var(--brand); text-decoration: none; }

/* Buttons inside the nav must keep their own colours. `.site-nav a` scores
   higher than `.btn-sm`, so without these the label inherits the dark link
   colour and vanishes against the purple fill. */
.site-nav a.btn,
.site-nav a.btn-sm,
.site-nav a.btn:hover,
.site-nav a.btn-sm:hover { color: #fff; }

.site-nav a.btn.ghost,
.site-nav a.btn-sm.ghost,
.site-nav a.btn.ghost:hover,
.site-nav a.btn-sm.ghost:hover { color: var(--brand); }

/* ── Buttons ────────────────────────────────────────────── */

.btn, .btn-sm {
  display: inline-block; background: var(--brand); color: #fff;
  border: 1px solid var(--brand); border-radius: 5px;
  font-family: inherit; font-weight: 600; cursor: pointer; text-align: center;
}
.btn { padding: 12px 26px; font-size: 16px; }
.btn-sm { padding: 8px 16px; font-size: 14px; }
.btn:hover, .btn-sm:hover { background: var(--brand-dark); color: #fff; text-decoration: none; }

.btn.ghost, .btn-sm.ghost { background: transparent; color: var(--brand); }
.btn.ghost:hover, .btn-sm.ghost:hover { background: var(--bg-soft); color: var(--brand); }

.btn.accent { background: var(--accent); border-color: var(--accent); }
.btn.accent:hover { filter: brightness(.92); }

.btn[disabled], .btn-sm[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────── */

label { display: block; font-weight: 600; font-size: 14px; margin: 16px 0 6px; }
label .hint { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 2px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=url], input[type=file],
select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 15px;
  border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--ink);
}
textarea { min-height: 130px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(73, 0, 102, .12);
}
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > * { flex: 1 1 200px; }

/* ── Flash messages ─────────────────────────────────────── */

.flash {
  max-width: 1080px; margin: 16px auto; padding: 12px 16px;
  border-radius: 5px; font-size: 15px; border-left: 3px solid;
}
.flash-ok    { background: #eaf6ea; color: #245c24; border-color: var(--ok); }
.flash-error { background: #fdeaea; color: var(--err); border-color: var(--err); }
.flash-warn  { background: #fff8e6; color: #7a5b12; border-color: var(--accent); }
.flash-info  { background: #eef2f7; color: #26415f; border-color: var(--brand); }

/* ── Cards & panels ─────────────────────────────────────── */

.card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.panel { background: var(--bg-soft); border-radius: var(--radius); padding: 20px; }

.grid { display: grid; gap: 22px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ── Auth pages ─────────────────────────────────────────── */

.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft); padding: 32px 16px;
}
.auth-card {
  width: 100%; max-width: 420px; background: #fff;
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.auth-head { background: var(--brand); color: #fff; padding: 24px 28px; }
.auth-head .t { font-family: var(--serif); font-size: 20px; font-weight: 700; }
.auth-head .s { font-size: 13px; color: rgba(255,255,255,.75); margin-top: 3px; }
.auth-body { padding: 26px 28px 30px; }
.auth-body .btn { width: 100%; margin-top: 22px; }
.auth-alt {
  margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 14px; color: var(--muted); text-align: center;
}

/* ── Footer ─────────────────────────────────────────────── */

.site-foot { background: var(--brand-dark); color: rgba(255,255,255,.8); margin-top: 72px; }
.foot-inner {
  display: grid; gap: 28px; padding-top: 44px; padding-bottom: 32px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.foot-col a, .foot-col span { display: block; color: rgba(255,255,255,.8); font-size: 14px; margin-bottom: 6px; }
.foot-col a:hover { color: #fff; }
.foot-col a.btn, .foot-col a.btn-sm { color: #fff; }
.foot-brand { font-family: var(--serif); font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.foot-h { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); margin-bottom: 10px; }
.foot-bar {
  border-top: 1px solid rgba(255,255,255,.12); padding: 16px 20px;
  text-align: center; font-size: 13px; color: rgba(255,255,255,.55);
}

/* ── Admin ──────────────────────────────────────────────── */

body.admin { background: var(--bg-soft); }

.admin-head { background: var(--brand); color: #fff; }
.admin-head-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 20px; min-height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.admin-brand { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.admin-brand:hover { text-decoration: none; }
.admin-head-right { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.admin-head-right a { color: rgba(255,255,255,.9); }
.admin-head-right .muted { color: rgba(255,255,255,.6); }

.admin-shell {
  max-width: 1320px; margin: 0 auto; padding: 24px 20px 60px;
  display: grid; grid-template-columns: 232px 1fr; gap: 26px; align-items: start;
}
.admin-side nav { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 20px; }
.admin-link {
  display: block; padding: 10px 13px; border-radius: 6px;
  color: var(--ink); background: transparent; border: 1px solid transparent;
}
.admin-link strong { display: block; font-size: 14.5px; font-weight: 600; }
.admin-link span { display: block; font-size: 12px; color: var(--muted); }
.admin-link:hover { background: #fff; border-color: var(--line); text-decoration: none; }
.admin-link.active { background: #fff; border-color: var(--line); box-shadow: var(--shadow); }
.admin-link.active strong { color: var(--brand); }
.admin-link.pending { opacity: .45; cursor: default; }
.admin-link.pending:hover { background: transparent; border-color: transparent; }

.admin-main { min-width: 0; }
.admin-title { font-family: var(--serif); font-size: 27px; margin: 0 0 20px; }

.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .n { font-size: 29px; font-weight: 700; color: var(--brand); line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 4px; }

table.data { width: 100%; border-collapse: collapse; background: #fff; font-size: 14.5px; }
table.data th {
  text-align: left; background: var(--brand); color: #fff;
  padding: 10px 12px; font-size: 13px; font-weight: 600;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.data tr:nth-child(even) td { background: #fafbfc; }
table.data tr:hover td { background: #f2f5f8; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600; background: var(--bg-soft); color: var(--muted);
}
.badge.ok { background: #eaf6ea; color: var(--ok); }
.badge.warn { background: #fff8e6; color: #7a5b12; }
.badge.err { background: #fdeaea; color: var(--err); }

.empty {
  text-align: center; padding: 46px 20px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius); background: #fff;
}

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li {
  padding: 11px 0; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 11px; font-size: 15px;
}
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { color: var(--ok); font-weight: 700; }
.checklist .todo { color: var(--muted); }

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .admin-link { flex: 1 1 140px; }
  .admin-link span { display: none; }
}

@media (max-width: 620px) {
  .head-inner { min-height: 0; padding-top: 12px; padding-bottom: 12px; }
  .brand img { max-height: 46px; }
  .site-nav { gap: 14px; font-size: 14px; }
  body { font-size: 15.5px; }
}

@media print {
  .site-head, .site-foot, .admin-side, .admin-head { display: none; }
}

/* ══════════════════════════════════════════════════════════
   MARKETING SITE
   ══════════════════════════════════════════════════════════ */

.eyebrow {
  font-size: 12px; letter-spacing: 2.2px; text-transform: uppercase;
  font-weight: 700; color: var(--brand); margin: 0 0 10px;
}
.eyebrow.gold { color: var(--accent); }

.lede { font-size: 17.5px; color: var(--muted); max-width: 60ch; margin: 0 0 18px; }

.section { padding: 78px 0; }
.section.alt { background: var(--bg-soft); }
.section-head { max-width: 660px; margin: 0 auto 44px; text-align: center; }
.section-head .lede { margin-left: auto; margin-right: auto; }

/* ── Hero ───────────────────────────────────────────────── */

.hero {
  background:
    radial-gradient(1100px 460px at 85% -10%, rgba(178,133,0,.10), transparent 60%),
    linear-gradient(160deg, #fbf9fc 0%, #f4eef7 100%);
  border-bottom: 1px solid var(--line);
  padding: 72px 0 66px;
}
.hero-inner {
  display: grid; grid-template-columns: 1.15fr .85fr;
  gap: 48px; align-items: center;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 54px); margin: 0 0 18px;
  color: var(--brand-dark); letter-spacing: -.5px;
}
.hero-sub { font-size: 19px; color: #4a4a52; max-width: 52ch; margin: 0 0 30px; }
.hero-cta { display: flex; gap: 13px; flex-wrap: wrap; }
.hero-art img { margin: 0 auto; max-width: 400px; }

/* ── Featured ───────────────────────────────────────────── */

.feat-inner { display: grid; grid-template-columns: 320px 1fr; gap: 52px; align-items: center; }
.feat-cover img, .feat-cover .cover-placeholder {
  border-radius: 6px; box-shadow: 0 18px 44px rgba(46, 0, 64, .22);
}
.feat-sub { font-size: 18px; color: var(--muted); margin: -6px 0 16px; font-style: italic; }
.feat-meta {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
  margin: 22px 0; font-size: 14px; color: var(--muted);
}
.price { font-weight: 700; color: var(--brand); font-size: 19px; }

.cover-placeholder {
  aspect-ratio: 2 / 3; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff; padding: 22px; text-align: center; border-radius: 6px;
}
.cover-placeholder span { font-family: var(--serif); font-size: 18px; line-height: 1.35; }

/* ── About ──────────────────────────────────────────────── */

.about-inner { display: grid; grid-template-columns: 320px 1fr; gap: 52px; align-items: start; }
.about-inner:has(.about-text:only-child) { grid-template-columns: 1fr; max-width: 760px; }
.about-photo { max-width: 340px; }
.about-photo img {
  border-radius: 8px; box-shadow: var(--shadow-lg);
  width: 100%; aspect-ratio: 2 / 3; object-fit: cover; object-position: center top;
}
.prose p { margin: 0 0 16px; }

/* ── Book grid ──────────────────────────────────────────── */

.book-grid {
  display: grid; gap: 30px;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
}
.book-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .16s ease, box-shadow .16s ease;
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.book-cover { display: block; position: relative; }
.book-cover img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; }
.ribbon {
  position: absolute; top: 12px; right: 0; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  padding: 5px 12px; border-radius: 3px 0 0 3px;
}
.book-info { padding: 18px; display: flex; flex-direction: column; flex: 1; }
.book-info h3 { font-family: var(--serif); font-size: 18px; margin: 0 0 4px; }
.book-sub { font-size: 14px; color: var(--muted); font-style: italic; margin: 0 0 10px; }
.book-desc { font-size: 14.5px; color: var(--muted); margin: 0 0 16px; flex: 1; }
.book-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ── Events ─────────────────────────────────────────────── */

.event-card {
  display: flex; gap: 18px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; color: inherit;
  transition: transform .16s ease, box-shadow .16s ease;
}
.event-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); text-decoration: none; }
.event-date {
  flex: 0 0 62px; text-align: center; background: var(--brand); color: #fff;
  border-radius: 6px; padding: 10px 6px; height: fit-content;
}
.event-date .d { display: block; font-size: 24px; font-weight: 700; line-height: 1; }
.event-date .m { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-top: 3px; }
.event-body h3 { font-size: 17px; margin: 0 0 5px; }

/* ── Services & quotes ──────────────────────────────────── */

.service-card {
  background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: var(--radius); padding: 26px 24px;
}
.service-card h3 { font-family: var(--serif); font-size: 19px; margin: 0 0 10px; color: var(--brand); }
.service-card p { font-size: 15px; color: var(--muted); margin: 0 0 12px; }

.quote-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 24px; margin: 0; position: relative;
}
.quote-card::before {
  content: '\201C'; font-family: var(--serif); font-size: 62px; line-height: 1;
  color: var(--accent); opacity: .32; position: absolute; top: 10px; left: 18px;
}
.quote-card blockquote { margin: 14px 0 16px; font-size: 15.5px; font-style: italic; position: relative; }
.quote-card figcaption { font-size: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.quote-card figcaption span { display: block; font-size: 13px; }

/* ── Newsletter ─────────────────────────────────────────── */

.newsletter { background: var(--brand); color: #fff; }
.newsletter h2 { color: #fff; }
.newsletter .lede { color: rgba(255,255,255,.82); }
.nl-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; }
.nl-form { display: flex; gap: 11px; flex-wrap: wrap; }
.nl-form input { flex: 1 1 230px; border: 0; padding: 13px 15px; }
.nl-form .btn { flex: 0 0 auto; }

/* ── Contact ────────────────────────────────────────────── */

.contact-inner { display: grid; grid-template-columns: 1fr 1.1fr; gap: 52px; align-items: start; }
.contact-list { list-style: none; padding: 0; margin: 24px 0 0; }
.contact-list li { padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.contact-list li span {
  display: block; font-size: 12px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); margin-bottom: 2px;
}
.contact-form { position: relative; }
.contact-form .btn { margin-top: 20px; }

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 900px) {
  .hero-inner, .feat-inner, .about-inner, .contact-inner, .nl-inner {
    grid-template-columns: 1fr;
  }
  .hero-art { order: -1; }
  .hero-art img { max-width: 260px; }
  .feat-cover { max-width: 240px; margin: 0 auto; }
  .about-photo { max-width: 260px; }
  .section { padding: 58px 0; }
}
