/* Ask Poe — one dark, candlelit theme for every page. */
:root {
  --ink: #0d0b0a;
  --soot: #15110f;
  --soot-2: #1d1815;
  --parchment: #e8dcc2;
  --parchment-deep: #d9c9a6;
  --faded: #a89a83;
  --crimson: #8b1a1a;
  --crimson-hi: #a32424;
  --gold: #c9a14a;
  --rule: rgba(201, 161, 74, .28);
  --body: "EB Garamond", Garamond, Georgia, serif;
  --caps: "Cormorant SC", "EB Garamond", Georgia, serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--parchment);
  font-family: var(--body); font-size: 18px; line-height: 1.55;
  display: flex; flex-direction: column;
}
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
h1, h2, h3 { font-weight: 500; line-height: 1.15; text-wrap: balance; margin: 0; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px clamp(16px, 3vw, 40px);
  background: var(--ink); border-bottom: 1px solid var(--rule);
  position: relative; z-index: 2;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 1.9rem; font-weight: 500; letter-spacing: .01em; white-space: nowrap; }
.brand img { width: 52px; height: auto; filter: brightness(0) invert(.88) sepia(.25); }
.brand .poe { color: var(--crimson-hi); }
.nav { display: flex; gap: clamp(20px, 3vw, 48px); margin: 0 auto; font-size: 1.08rem; }
.nav a { color: var(--parchment); opacity: .9; padding-block: 4px; border-bottom: 1px solid transparent; }
.nav a:hover { color: var(--gold); opacity: 1; }
.nav a[aria-current="page"] { color: var(--gold); border-bottom-color: var(--gold); }
.motto { font-style: italic; color: var(--parchment-deep); white-space: nowrap; }

/* ---------- footer ---------- */
footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px;
  padding: 16px clamp(16px, 3vw, 40px); border-top: 1px solid var(--rule); background: var(--ink); font-size: 1rem;
}
footer nav { display: flex; flex-wrap: wrap; }
footer nav a + a::before { content: "|"; margin: 0 1.1em; color: var(--rule); }
footer nav a:hover { color: var(--gold); }

/* ---------- shared pieces ---------- */
.ask {
  width: min(800px, 100%); display: flex;
  border: 2px solid var(--gold); border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 4px rgba(13,11,10,.55), 0 14px 44px rgba(0,0,0,.7);
}
.ask label { display: flex; align-items: center; flex: 1; min-width: 0; gap: 12px; padding: 0 18px;
  background: linear-gradient(180deg, var(--parchment), var(--parchment-deep)); }
.ask label svg { width: 24px; height: 24px; flex: none; stroke: #2a211b; fill: none; stroke-width: 2; }
.ask input {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 18px 0;
  font: inherit; font-size: 1.25rem; color: #1d1712;
}
.ask input::placeholder { color: #5f5446; }
.ask input:focus { outline: none; }
.ask:focus-within { box-shadow: 0 0 0 4px rgba(201,161,74,.35), 0 14px 44px rgba(0,0,0,.7); }
.ask button {
  display: flex; align-items: center; gap: 14px;
  border: 0; border-left: 2px solid var(--gold); cursor: pointer;
  padding: 0 28px; background: var(--crimson); color: var(--parchment);
  font-family: var(--body); font-size: 1.35rem;
}
.ask button:hover { background: var(--crimson-hi); }
.ask button:disabled { cursor: progress; opacity: .7; }
.ask button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }
.flourish { width: 18px; height: 18px; fill: var(--gold); }
.button {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 6px;
  border: 1px solid var(--gold); color: var(--parchment); background: var(--crimson); font-size: 1rem; cursor: pointer;
}
.button:hover { background: var(--crimson-hi); }
.button.ghost { background: transparent; }
.button.ghost:hover { background: rgba(201,161,74,.12); }

/* ---------- home ---------- */
.hero {
  flex: 1; position: relative; isolation: isolate;
  display: grid; place-items: center;
  padding: clamp(32px, 6vh, 72px) 16px clamp(24px, 4vh, 48px);
  background: var(--ink) url("/assets/hero-study.webp") center / cover no-repeat;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 42% 60% at 50% 42%, rgba(13,11,10,.35), transparent 75%),
    linear-gradient(to bottom, rgba(13,11,10,.25), transparent 30%, transparent 62%, rgba(13,11,10,.9));
}
.center { width: min(820px, 100%); display: grid; justify-items: center; gap: clamp(20px, 3.5vh, 34px); text-align: center; }
.logo { width: min(500px, 88%); height: auto; filter: drop-shadow(0 8px 22px rgba(0,0,0,.75)); }
.doors { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.doors li + li { border-left: 1px solid var(--rule); }
.doors a { display: grid; justify-items: center; gap: 10px; padding: 4px 26px; font-size: 1.12rem; line-height: 1.25; color: var(--parchment); }
.doors a:hover { color: var(--gold); }
.doors svg { width: 46px; height: 46px; stroke: var(--gold); fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.quote {
  position: absolute; right: clamp(16px, 3vw, 48px); bottom: clamp(24px, 5vh, 56px);
  width: 220px; padding: 14px 10px; margin: 0; text-align: center; font-style: italic; font-size: 1.3rem; line-height: 1.45;
  background: radial-gradient(ellipse at center, rgba(13,11,10,.75), transparent 72%);
  text-shadow: 0 2px 10px #000, 0 0 2px #000;
}
.quote cite { display: block; margin-top: 12px; font-family: var(--caps); font-style: normal; font-size: .8rem; letter-spacing: .12em; color: var(--parchment-deep); }
.hero-foot { display: grid; justify-items: center; gap: 8px; margin-top: clamp(16px, 5vh, 56px); }
.hero-foot p { font-style: italic; font-size: 1.12rem; }
.themes { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 0; font-family: var(--caps); font-size: .95rem; letter-spacing: .12em; color: var(--parchment-deep); }
.themes b { font-weight: inherit; white-space: nowrap; }
.themes span { margin: 0 .7em; color: var(--gold); }

/* ---------- inner pages ---------- */
.page {
  flex: 1; position: relative; isolation: isolate;
  padding: clamp(28px, 5vh, 56px) 16px 56px;
  background: var(--ink) url("/assets/hero-study.webp") center top / cover no-repeat fixed;
}
.page::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to bottom, rgba(13,11,10,.86), rgba(13,11,10,.96) 40%); }
.wrap { width: min(960px, 100%); margin: 0 auto; display: grid; gap: 28px; }
.wrap.narrow { width: min(720px, 100%); }
.page-head { display: grid; gap: 10px; justify-items: center; text-align: center; padding-bottom: 6px; }
.eyebrow { font-family: var(--caps); font-size: .95rem; letter-spacing: .16em; color: var(--gold); }
.page-head h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); }
.page-head p { color: var(--parchment-deep); font-style: italic; max-width: 60ch; font-size: 1.12rem; }
.divider { display: flex; align-items: center; gap: 12px; width: min(360px, 80%); margin: 4px auto 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.divider::after { background: linear-gradient(90deg, var(--gold), transparent); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card {
  display: grid; gap: 8px; align-content: start; padding: 20px 22px;
  background: rgba(21,17,15,.88); border: 1px solid var(--rule); border-radius: 6px;
  transition: border-color .2s, transform .2s;
}
a.card:hover { border-color: var(--gold); transform: translateY(-2px); }
.card h2, .card h3 { font-size: 1.45rem; }
.card p { color: var(--parchment-deep); font-size: 1.02rem; }
.card .ask-line { color: var(--gold); font-style: italic; font-size: 1rem; }
.card .meta { font-family: var(--caps); letter-spacing: .1em; font-size: .85rem; color: var(--faded); }
.card .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

.section { display: grid; gap: 14px; }
.section > h2 { font-size: 1.8rem; display: flex; align-items: baseline; gap: 12px; }
.section > h2 small { font-family: var(--caps); font-size: .9rem; letter-spacing: .12em; color: var(--faded); }
.works { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 28px; }
.works li { border-bottom: 1px solid var(--rule); }
.works a { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 2px; }
.works a:hover .t { color: var(--gold); }
.works .t { font-size: 1.15rem; }
.works .y { font-variant-numeric: tabular-nums; color: var(--faded); font-size: .95rem; }

.prose { display: grid; gap: 16px; background: rgba(21,17,15,.88); border: 1px solid var(--rule); border-radius: 6px; padding: clamp(20px, 4vw, 36px); }
.prose h2 { font-size: 1.5rem; margin-top: 8px; color: var(--gold); }
.prose p, .prose li { color: var(--parchment); max-width: 68ch; }
.prose ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.prose a { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
.prose .note { color: var(--faded); font-style: italic; font-size: .98rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 6px; background: rgba(21,17,15,.88); }
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th { font-family: var(--caps); font-weight: 500; letter-spacing: .1em; color: var(--gold); font-size: .9rem; }
td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }
tr:last-child td { border-bottom: 0; }
td a { color: var(--gold); }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; border: 1px solid var(--rule); font-size: .85rem; color: var(--parchment-deep); }
.pill.ok { border-color: rgba(201,161,74,.6); color: var(--gold); }
.pill.off { color: var(--faded); }

/* ---------- chat ---------- */
.chat { flex: 1; display: grid; grid-template-rows: 1fr auto; position: relative; isolation: isolate;
  background: var(--ink) url("/assets/hero-study.webp") center / cover no-repeat fixed; }
.chat::before { content: ""; position: absolute; inset: 0; z-index: -1; background: rgba(13,11,10,.9); }
.log { width: min(820px, 100%); margin: 0 auto; padding: 28px 16px 32px; display: grid; align-content: start; gap: 26px; }
.log-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.log-head h1 { font-size: 1.9rem; }
.scope { display: inline-flex; align-items: center; gap: 8px; font-size: .98rem; color: var(--parchment-deep); }
.scope a { color: var(--gold); }
.empty { text-align: center; color: var(--parchment-deep); font-style: italic; padding: 40px 0; display: grid; gap: 14px; justify-items: center; }
.empty img { width: 90px; opacity: .85; }
.q { justify-self: end; max-width: 85%; padding: 10px 16px; border-radius: 10px 10px 2px 10px;
  background: rgba(232,220,194,.1); border: 1px solid var(--rule); font-style: italic; }
.a { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; }
.a .seal { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--soot-2); border: 1px solid var(--gold); }
.a .seal img { width: 30px; filter: brightness(0) invert(.88) sepia(.25); }
.a .body { display: grid; gap: 12px; min-width: 0; }
.a .text { display: grid; gap: 12px; font-size: 1.12rem; line-height: 1.65; }
.a .text p { white-space: pre-line; }
.a .text sup a { color: var(--gold); font-size: .78em; padding: 0 1px; }
.a .text.declined { font-style: italic; color: var(--parchment-deep); }
.a .text.error { color: #e3a3a3; }
.writing { display: inline-flex; align-items: center; gap: 10px; color: var(--faded); font-style: italic; }
.writing i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: blink 1.2s infinite; }
.writing i:nth-child(2) { animation-delay: .2s; } .writing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.sources { border-top: 1px solid var(--rule); padding-top: 10px; font-size: .95rem; }
.sources summary { cursor: pointer; font-family: var(--caps); letter-spacing: .1em; color: var(--gold); font-size: .9rem; }
.sources ol { margin: 8px 0 0; padding-left: 1.4em; display: grid; gap: 4px; color: var(--parchment-deep); }
.sources li.cited { color: var(--parchment); }
.sources li:target { background: rgba(201,161,74,.15); border-radius: 4px; }
.sources a { color: var(--gold); text-decoration: underline; text-underline-offset: 2px; }
.sources .site { color: var(--faded); }
.composer { position: sticky; bottom: 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--ink) 60%, transparent); display: grid; justify-items: center; gap: 8px; }
.composer .hint { font-size: .9rem; color: var(--faded); }
.composer .hint a { color: var(--gold); }

/* ---------- sound ---------- */
.tools { display: flex; align-items: center; gap: 18px; }
.ambience { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: transparent; border: 1px solid var(--rule); color: var(--parchment); cursor: pointer; }
.ambience svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.ambience .waves { opacity: .35; }
.ambience[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.ambience[aria-pressed="true"] .waves { opacity: 1; }
.ambience:hover { border-color: var(--gold); }
.ask .mic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; color: #2a211b; }
.ask .mic[hidden] { display: none; }
.ask .mic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ask .mic:hover { background: rgba(42,33,27,.1); }
.ask .mic.listening { color: var(--crimson-hi); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(163,36,36,.45); } 50% { box-shadow: 0 0 0 8px rgba(163,36,36,0); } }
.hear { justify-self: start; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 10px;
  border-radius: 999px; border: 1px solid var(--gold); background: transparent; color: var(--gold);
  font: inherit; font-size: .98rem; cursor: pointer; }
.hear svg { width: 16px; height: 16px; fill: currentColor; }
.hear:hover { background: rgba(201,161,74,.12); }
.hear[data-state="playing"] svg path { d: path("M7 5h3v14H7zM14 5h3v14h-3z"); }
.hear[data-state="error"] { color: #e3a3a3; border-color: #e3a3a3; }
.readings { display: grid; gap: 18px; }
.reading audio { width: 100%; margin-top: 4px; }
.reading details summary { cursor: pointer; font-family: var(--caps); letter-spacing: .1em; color: var(--gold); font-size: .9rem; }
.reading .verse { white-space: pre-line; margin-top: 10px; line-height: 1.75; font-size: 1.08rem; }

@media (max-width: 1180px) { .quote { display: none; } }
@media (max-width: 900px) {
  .motto { display: none; }
  .nav { order: 4; flex-basis: 100%; justify-content: center; flex-wrap: wrap; gap: 12px 22px; margin: 0; font-size: 1rem; }
  .tools { order: 3; }
  .topbar { justify-content: space-between; flex-wrap: wrap; row-gap: 12px; }

}
@media (min-width: 901px) { .menu { display: none; } }
.menu { gap: 14px; font-size: 1rem; flex-wrap: wrap; justify-content: flex-end; }
.menu a[aria-current="page"] { color: var(--gold); }
@media (max-width: 640px) {
  body { font-size: 17px; }
  .brand { font-size: 1.5rem; } .brand img { width: 40px; }
  .hero { background-position: 20% center; }
  .hero::before { background: linear-gradient(to bottom, rgba(13,11,10,.55), rgba(13,11,10,.75) 40%, rgba(13,11,10,.95)); }
  .ask { flex-direction: column; border-radius: 8px; }
  .ask button { border-left: 0; border-top: 2px solid var(--gold); justify-content: center; padding: 14px; }
  .composer .ask { flex-direction: row; }
  .composer .ask button { border-top: 0; border-left: 2px solid var(--gold); padding: 0 16px; font-size: 1.1rem; }
  .composer .ask input { font-size: 1.05rem; padding: 14px 0; }
  .doors { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 22px; }
  .doors li:nth-child(3) { border-left: 0; }
  .doors a { padding: 4px 10px; }
  footer { justify-content: center; text-align: center; }
  .a { grid-template-columns: minmax(0, 1fr); }
  .a .seal { display: none; }
  .page, .chat { background-attachment: scroll; }
}
@media (prefers-reduced-motion: reduce) {
  .writing i, .ask .mic.listening { animation: none; opacity: .7; }
  a.card { transition: none; }
}

.conversation-help { margin: 1rem 0; font-size: .9rem; }
#conversation-reference { overflow-wrap: anywhere; user-select: all; }

.contact-form { display: grid; gap: .7rem; margin: 1.5rem 0; }
.contact-form input, .contact-form select, .contact-form textarea { width: 100%; padding: .7rem; border: 1px solid var(--gold); background: var(--parchment); color: #211b16; font: inherit; border-radius: 4px; }
.contact-form .button { justify-self: start; }
.contact-trap { display: none; }
