/* ============================================================
   THE LORE COUNCIL — Dark Academia
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=IM+Fell+English+SC&display=swap');

:root {
  --ink-deepest:       #0a0604;
  --ink:               #150e08;
  --ink-soft:          #1f1610;
  --mahogany:          #2d1c0f;
  --mahogany-light:    #3d2616;
  --leather:           #4a2f1a;
  --leather-light:     #5e3d23;

  --gold:              #c9a961;
  --gold-bright:       #e8c389;
  --gold-deep:         #8a6f35;
  --candle:            #f0c878;
  --candle-warm:       #d99449;

  --parchment:         #e8d9b5;
  --parchment-warm:    #d8c594;
  --parchment-deep:    #b89f6c;
  --cream:             #f3e6c5;

  --burgundy:          #6b1e1e;
  --burgundy-deep:     #4a1212;

  --shadow-deep:       0 30px 80px rgba(0,0,0,0.7);
  --shadow-glow:       0 0 60px rgba(217,148,73,0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--ink-deepest);
  color: var(--cream);
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── typography ──────────────────────────────────────────── */
.serif-display { font-family: 'Cormorant Garamond', 'Times New Roman', serif; font-weight: 500; letter-spacing: 0.01em; }
.smallcaps {
  font-family: 'IM Fell English SC', 'Cormorant Garamond', serif;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--gold);
}
.italic { font-style: italic; color: var(--parchment-warm); }

/* ── texture utilities ───────────────────────────────────── */
.paper-grain { position: relative; }
.paper-grain::before {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.4  0 0 0 0 0.3  0 0 0 0 0.15  0 0 0 0.35 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  opacity: 0.5;
  mix-blend-mode: multiply;
  border-radius: inherit;
}

.leather-grain { position: relative; }
.leather-grain::before {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='l'><feTurbulence type='fractalNoise' baseFrequency='0.5' numOctaves='3' stitchTiles='stitch' seed='4'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23l)'/></svg>");
  opacity: 0.35;
  mix-blend-mode: overlay;
  border-radius: inherit;
}

/* ── ambient room ────────────────────────────────────────── */
.chamber-bg {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 35%, rgba(217,148,73,0.10), transparent 70%),
    radial-gradient(ellipse 50% 40% at 12% 30%, rgba(217,148,73,0.08), transparent 70%),
    radial-gradient(ellipse 50% 40% at 88% 30%, rgba(217,148,73,0.08), transparent 70%),
    radial-gradient(ellipse 100% 100% at 50% 100%, #1a0e06 0%, var(--ink-deepest) 60%),
    var(--ink-deepest);
}
.chamber-bg::after {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.25  0 0 0 0 0.18  0 0 0 0 0.08  0 0 0 0.4 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.5'/></svg>");
  mix-blend-mode: overlay;
  opacity: 0.6;
  pointer-events: none;
}

.vignette {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse 110% 90% at 50% 50%, transparent 50%, rgba(0,0,0,0.55) 90%, rgba(0,0,0,0.85) 100%);
}

/* ── candle flame ────────────────────────────────────────── */
@keyframes flicker {
  0%, 100% { opacity: 1;    transform: scale(1) translateY(0);         filter: blur(0.5px); }
  20%       { opacity: 0.92; transform: scale(0.97,1.04) translateY(-0.5px); }
  40%       { opacity: 0.97; transform: scale(1.02,0.98) translateY(0.3px);  filter: blur(0.7px); }
  60%       { opacity: 0.88; transform: scale(0.98,1.02) translateY(-0.4px); }
  80%       { opacity: 0.95; transform: scale(1.01,0.99) translateY(0.2px);  }
}
@keyframes glow-pulse {
  0%, 100% { opacity: 0.85; }
  50%       { opacity: 1; }
}
.candle-flame {
  display: inline-block;
  width: 8px; height: 14px;
  background: radial-gradient(ellipse at 50% 70%, #ffe9a8 0%, #f0c878 35%, #d99449 70%, transparent 100%);
  border-radius: 50% 50% 40% 40% / 60% 60% 40% 40%;
  filter: blur(0.4px) drop-shadow(0 0 12px #f0c878) drop-shadow(0 0 22px rgba(217,148,73,0.8));
  animation: flicker 1.8s ease-in-out infinite;
  transform-origin: 50% 100%;
}

/* ── buttons / seals ─────────────────────────────────────── */
.wax-seal {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 88px; height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8a2828 0%, #6b1e1e 40%, #3a0e0e 100%);
  box-shadow:
    inset 0 -4px 10px rgba(0,0,0,0.6),
    inset 0 4px 8px rgba(255,180,180,0.18),
    0 6px 18px rgba(0,0,0,0.7);
  font-family: 'IM Fell English SC', serif;
  color: #f0d8c0;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  transition: transform 0.25s ease;
}
.wax-seal:hover { transform: scale(1.04) rotate(-2deg); }

.gold-seal-button {
  position: relative;
  padding: 22px 56px;
  border: none;
  background: radial-gradient(ellipse at 50% 35%, #f0d090 0%, #c9a961 40%, #8a6f35 100%);
  border-radius: 50%/40px;
  font-family: 'IM Fell English SC', serif;
  font-size: 0.92rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #1a0e04;
  cursor: pointer;
  box-shadow:
    inset 0 2px 4px rgba(255,230,180,0.6),
    inset 0 -3px 8px rgba(80,50,15,0.6),
    0 8px 24px rgba(0,0,0,0.6),
    0 0 0 1px rgba(80,50,15,0.4);
  transition: all 0.4s cubic-bezier(0.4,0,0.2,1);
}
.gold-seal-button:disabled {
  background: radial-gradient(ellipse at 50% 35%, #4a4030 0%, #2e2618 40%, #1a1308 100%);
  color: #5a4a30;
  cursor: not-allowed;
  box-shadow:
    inset 0 2px 4px rgba(80,70,50,0.3),
    inset 0 -3px 8px rgba(0,0,0,0.6),
    0 4px 12px rgba(0,0,0,0.5);
}
.gold-seal-button:not(:disabled) {
  animation: glow-pulse 3.2s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(217,148,73,0.5));
}
.gold-seal-button:not(:disabled):hover {
  transform: translateY(-2px);
  filter: drop-shadow(0 0 28px rgba(240,200,120,0.7));
}

/* ── portrait frame ──────────────────────────────────────── */
.portrait-frame {
  position: relative;
  width: 100%; aspect-ratio: 3/4;
  border-radius: 50%; overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #3a2a18 0%, #1a1108 90%);
  box-shadow:
    inset 0 0 0 2px #c9a961,
    inset 0 0 0 5px #2d1c0f,
    inset 0 0 0 7px #8a6f35,
    inset 0 0 30px rgba(0,0,0,0.8),
    0 4px 16px rgba(0,0,0,0.6);
}
.portrait-frame::before {
  content: '';
  position: absolute; inset: -8px;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    #8a6f35 0deg, #e8c389 20deg, #c9a961 45deg, #8a6f35 90deg,
    #e8c389 130deg, #c9a961 180deg, #8a6f35 220deg, #e8c389 270deg,
    #c9a961 310deg, #8a6f35 360deg);
  z-index: -1; filter: blur(0.4px);
}
.portrait-frame::after {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 25%, rgba(240,200,120,0.22) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 55%, transparent 35%, rgba(0,0,0,0.55) 100%);
  pointer-events: none; border-radius: inherit;
}
.portrait-frame img {
  width: 100%; height: 100%; object-fit: cover;
  filter: sepia(0.25) saturate(0.85) contrast(1.05) brightness(0.92);
}
.portrait-frame .placeholder-initials {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cormorant Garamond', serif; font-weight: 500;
  font-size: 2.4rem; color: var(--gold-bright);
  text-shadow: 0 0 20px rgba(240,200,120,0.5), 0 2px 6px rgba(0,0,0,0.8);
  letter-spacing: 0.05em;
}
.portrait-frame .upload-hint {
  position: absolute; bottom: 14%; left: 50%; transform: translateX(-50%);
  font-family: 'IM Fell English SC', serif; font-size: 0.55rem;
  letter-spacing: 0.2em; color: var(--gold);
  opacity: 0; transition: opacity 0.4s ease; white-space: nowrap;
}
.portrait-frame:hover .upload-hint { opacity: 0.9; }

/* ── panels ──────────────────────────────────────────────── */
.panel-leather {
  background: linear-gradient(160deg, #2d1c0f 0%, #1a0f06 100%);
  border: 1px solid var(--leather); border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(217,148,73,0.18),
    inset 0 0 60px rgba(0,0,0,0.5),
    0 12px 40px rgba(0,0,0,0.6);
  position: relative;
}
.panel-leather::after {
  content: '';
  position: absolute; inset: 8px;
  border: 1px solid rgba(201,169,97,0.22);
  pointer-events: none; border-radius: 2px;
}

.panel-parchment {
  background: linear-gradient(170deg, #e8d9b5 0%, #d8c594 100%);
  color: #2a1c10; border-radius: 2px;
  box-shadow:
    inset 0 0 40px rgba(120,90,40,0.25),
    inset 0 0 0 1px rgba(120,90,40,0.4),
    0 8px 24px rgba(0,0,0,0.5);
  position: relative;
}

/* ── rules / dividers ────────────────────────────────────── */
.rule-gold {
  height: 1px;
  background: linear-gradient(90deg, transparent, #c9a961 20%, #c9a961 80%, transparent);
  border: none; margin: 14px 0;
}
.rule-gold-ornate {
  display: flex; align-items: center; gap: 12px; margin: 18px 0;
}
.rule-gold-ornate::before, .rule-gold-ornate::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, #c9a961 50%, transparent);
}
.rule-gold-ornate .diamond {
  width: 6px; height: 6px;
  background: var(--gold); transform: rotate(45deg);
  box-shadow: 0 0 8px rgba(217,148,73,0.6);
}

/* ── dust motes ──────────────────────────────────────────── */
@keyframes drift {
  0%   { transform: translate(0,0);      opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.4; }
  100% { transform: translate(40px,-100px); opacity: 0; }
}
.dust-motes { position: fixed; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.dust-motes .mote {
  position: absolute; width: 2px; height: 2px;
  background: rgba(240,200,120,0.7); border-radius: 50%;
  filter: blur(0.5px); box-shadow: 0 0 4px rgba(240,200,120,0.6);
  animation: drift linear infinite;
}

/* ── top nav ─────────────────────────────────────────────── */
.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 36px;
  background: linear-gradient(to bottom, rgba(10,6,4,0.9), transparent);
  pointer-events: none;
}
.top-nav > * { pointer-events: auto; }
.top-nav .brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--gold-bright); text-shadow: 0 0 18px rgba(240,200,120,0.4);
  display: flex; align-items: center; gap: 12px;
}
.nav-links {
  display: flex; gap: 28px;
  font-family: 'IM Fell English SC', serif;
  font-size: 0.78rem; letter-spacing: 0.22em;
}
.nav-links a {
  color: var(--parchment-warm); text-decoration: none; cursor: pointer;
  padding-bottom: 4px; border-bottom: 1px solid transparent;
  transition: all 0.4s ease;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--gold-bright); border-bottom-color: var(--gold);
}

/* ── view transitions ────────────────────────────────────── */
@keyframes page-turn {
  0%   { opacity: 0; transform: translateY(12px); filter: blur(4px); }
  100% { opacity: 1; transform: translateY(0);    filter: blur(0); }
}
.view { animation: page-turn 1.1s cubic-bezier(0.2,0.8,0.2,1); }

/* ── form fields ─────────────────────────────────────────── */
.field-label {
  display: block;
  font-family: 'IM Fell English SC', serif;
  font-size: 0.7rem; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 6px;
}
.input-parchment, .textarea-parchment {
  width: 100%;
  background: linear-gradient(170deg, #e8d9b5 0%, #d4c290 100%);
  color: #2a1c10;
  border: 1px solid rgba(120,90,40,0.5); border-radius: 2px;
  padding: 12px 14px;
  font-family: 'EB Garamond', serif; font-size: 1rem;
  outline: none;
  box-shadow: inset 0 0 24px rgba(120,90,40,0.18);
  transition: box-shadow 0.3s ease; resize: vertical;
}
.input-parchment:focus, .textarea-parchment:focus {
  box-shadow: inset 0 0 24px rgba(120,90,40,0.18), 0 0 0 2px rgba(217,148,73,0.4);
}
.textarea-parchment::placeholder, .input-parchment::placeholder {
  color: rgba(60,40,18,0.5); font-style: italic;
}

/* ── model dropdown ──────────────────────────────────────── */
.model-select {
  position: relative; display: inline-flex; align-items: center; gap: 10px;
  background: linear-gradient(160deg, #2d1c0f, #1a0f06);
  border: 1px solid var(--gold-deep); padding: 10px 16px 10px 12px;
  cursor: pointer; user-select: none;
  font-family: 'EB Garamond', serif; color: var(--parchment); border-radius: 2px;
}
.model-select::before {
  content: ''; width: 10px; height: 10px; border-radius: 50%;
  background: var(--dot-color, radial-gradient(circle at 35% 30%, #8a2828, #4a1212));
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.6), 0 0 4px var(--dot-glow, rgba(107,30,30,0.6));
}
.model-select select {
  /* Transparent overlay covering the full bar — makes every pixel clickable */
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; z-index: 1;
}
.model-select::after { content: '▾'; position: absolute; right: 14px; color: var(--gold); }

/* ── swatch picker ───────────────────────────────────────── */
.swatch-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(0,0,0,0.4);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.5), inset 0 1px 2px rgba(255,255,255,0.15), 0 2px 6px rgba(0,0,0,0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.selected {
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.5),
    inset 0 1px 2px rgba(255,255,255,0.15),
    0 0 0 2px var(--gold-bright),
    0 0 14px rgba(240,200,120,0.7);
}

/* ── loading / deliberating state ────────────────────────── */
@keyframes deliberate-pulse {
  0%, 100% { opacity: 0.4; transform: scaleX(0.8); }
  50%       { opacity: 1;   transform: scaleX(1); }
}
.deliberating-bar {
  width: 120px; height: 2px; border-radius: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: deliberate-pulse 2.4s ease-in-out infinite;
  margin: 0 auto;
}

/* ── Markdown content ────────────────────────────────────── */
.md-content p                 { margin-bottom: 0.8em; }
.md-content p:last-child      { margin-bottom: 0; }
.md-content strong,
.md-content b                 { font-weight: 600; }
.md-content em,
.md-content i                 { font-style: italic; }
.md-content h1, .md-content h2, .md-content h3,
.md-content h4, .md-content h5, .md-content h6 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0.9em 0 0.4em;
  line-height: 1.2;
}
.md-content h1 { font-size: 1.35em; }
.md-content h2 { font-size: 1.2em; }
.md-content h3 { font-size: 1.08em; }
.md-content blockquote {
  border-left: 3px solid var(--gold-deep);
  margin: 0.8em 0;
  padding: 0.35em 1em;
  font-style: italic;
  opacity: 0.88;
}
.md-content code {
  font-family: 'Courier New', monospace;
  font-size: 0.87em;
  background: rgba(0,0,0,0.09);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}
.md-content ul,
.md-content ol {
  margin: 0.5em 0 0.6em 1.4em;
}
.md-content li { margin-bottom: 0.2em; }
.md-content hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-deep), transparent);
  margin: 1em 0;
}

/* Dark-background variant (follow-up chamber leather panels) */
.md-content.md-dark blockquote { border-left-color: var(--gold); }
.md-content.md-dark code        { background: rgba(255,255,255,0.12); }

/* Arbiter drop-capital on the first letter of the first paragraph */
.arbiter-summation p:first-of-type::first-letter {
  font-family: 'Cormorant Garamond', serif;
  font-size: 3.4rem;
  font-weight: 600;
  float: left;
  line-height: 0.85;
  padding-right: 10px;
  padding-top: 4px;
  color: #8a6f35;
}

/* ── scrollbars ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.4); }
::-webkit-scrollbar-thumb { background: var(--leather); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-deep); }
