/* ============================================================
   LORE UI — PSX × GOTHIC THEME
   Deep violet night + gold glow + pixel frames
   ============================================================ */

/* ── Google Fonts (fallback) ── */
@font-face {
  font-family: 'Press Start 2P';
  src: url('/static/fonts/PressStart2P.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cinzel';
  src: url('/static/fonts/Cinzel-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cinzel';
  src: url('/static/fonts/Cinzel-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/static/fonts/CormorantGaramond-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/static/fonts/CormorantGaramond-Bold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IM Fell English';
  src: url('/static/fonts/IMFellEnglish.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'MedievalSharp';
  src: url('/static/fonts/MedievalSharp.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pirata One';
  src: url('/static/fonts/PirataOne.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Rye';
  src: url('/static/fonts/Rye.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ── CSS Variables ── */
:root {
  /* Palette */
  --bg:           #07050d;
  --bg-elevated:  #120b1f;
  --bg-panel:     #1a0f2e;
  --paper:        #1e1038;
  --ink:          #d9c7a8;
  --ink-muted:    #9a8b72;
  --gold:         #c19a3b;
  --gold-bright:  #f0d57a;
  --gold-dim:     #8b6914;
  --crimson:      #8b2635;
  --ember:        #d4661f;
  --arcane:       #6b4d8a;
  --violet:       #4d3b7c;
  --moss:         #5d7c4a;

  /* Effect colors */
  --glow-gold:    rgba(193,154,59,0.5);
  --glow-arcane:  rgba(107,77,138,0.5);
  --glow-crimson: rgba(139,38,53,0.5);
  --shadow-deep:  rgba(0,0,0,0.85);

  /* Fonts */
  --font-psx:     'Press Start 2P', monospace;
  --font-title:   'Pirata One', 'MedievalSharp', serif;
  --font-heading: 'Cinzel', 'MedievalSharp', serif;
  --font-body:    'Cormorant Garamond', 'IM Fell English', Georgia, serif;
  --font-accent:  'IM Fell English', 'Cormorant Garamond', serif;
  --font-mono:    'Courier New', monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 27px/1.6 var(--font-body);
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--arcane);
  border-radius: 0;
  border: 1px solid var(--gold-dim);
}
::-webkit-scrollbar-thumb:hover { background: var(--violet); }

/* ── Noise overlay (shared) ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* ── Pixel frame (shared) ── */
.rune-frame {
  position: relative;
  border: 3px solid var(--gold);
  background: var(--bg-panel);
  /* Pixel corners via clip-path */
  clip-path: polygon(
    0 8px, 8px 8px, 8px 0,
    calc(100% - 8px) 0, calc(100% - 8px) 8px, 100% 8px,
    100% calc(100% - 8px), calc(100% - 8px) calc(100% - 8px), calc(100% - 8px) 100%,
    8px 100%, 8px calc(100% - 8px), 0 calc(100% - 8px)
  );
  box-shadow:
    0 0 0 1px var(--gold-dim),
    0 0 20px var(--glow-gold),
    inset 0 0 30px rgba(0,0,0,0.6);
}

.rune-frame::before,
.rune-frame::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: var(--gold);
  clip-path: polygon(0 0, 100% 0, 0 100%);
  opacity: 0.6;
}
.rune-frame::before { top: -1px; left: -1px; }
.rune-frame::after  { bottom: -1px; right: -1px; transform: rotate(180deg); }

/* ── Ornament corners ── */
.rune-corner {
  position: absolute;
  width: 60px;
  height: 60px;
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 10;
}
.rune-corner.tl { top: -4px; left: -4px; }
.rune-corner.tr { top: -4px; right: -4px; transform: scaleX(-1); }
.rune-corner.bl { bottom: -4px; left: -4px; transform: scaleY(-1); }
.rune-corner.br { bottom: -4px; right: -4px; transform: scale(-1,-1); }

/* ── Glow text ── */
.glow-gold {
  color: var(--gold-bright);
  text-shadow: 0 0 8px var(--gold), 0 0 16px var(--glow-gold);
}
.glow-arcane {
  color: #a78bfa;
  text-shadow: 0 0 8px var(--arcane), 0 0 16px var(--glow-arcane);
}
.glow-crimson {
  color: #f87171;
  text-shadow: 0 0 8px var(--crimson), 0 0 16px var(--glow-crimson);
}

/* ── Masthead / Header ── */
.masthead {
  padding: 24px 32px 20px;
  border-bottom: 2px solid var(--gold-dim);
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}
.masthead::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.masthead .title-rune {
  font-family: var(--font-title);
  font-size: 42px;
  color: var(--gold-bright);
  text-shadow: 0 0 10px var(--gold), 0 0 24px var(--glow-gold);
  letter-spacing: 0.05em;
}

.masthead .ink-meta {
  font-family: var(--font-accent);
  font-size: 21px;
  color: var(--ink-muted);
  font-style: italic;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  padding: 16px 24px 0;
  background: var(--bg);
}
.tab-link {
  font-family: var(--font-heading);
  font-size: 19px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-decoration: none;
  padding: 8px 16px;
  border: 2px solid transparent;
  border-bottom: none;
  background: var(--bg-panel);
  position: relative;
  transition: color 0.2s, background 0.2s;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}
.tab-link:hover {
  color: var(--gold-bright);
  background: var(--bg-elevated);
  text-shadow: 0 0 6px var(--glow-gold);
}
.tab-link.active {
  color: var(--gold-bright);
  border-color: var(--gold);
  background: var(--bg-elevated);
  text-shadow: 0 0 8px var(--gold);
  z-index: 1;
}

/* ── Buttons ── */
.btn {
  font-family: var(--font-psx);
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--ink);
  background: var(--bg-panel);
  border: 2px solid var(--gold-dim);
  padding: 8px 14px;
  cursor: pointer;
  text-transform: uppercase;
  position: relative;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
  transition: all 0.15s;
}
.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 50%);
  pointer-events: none;
}
.btn:hover {
  color: var(--gold-bright);
  border-color: var(--gold);
  box-shadow: 0 0 10px var(--glow-gold), inset 0 0 10px rgba(193,154,59,0.1);
  text-shadow: 0 0 6px var(--gold);
}
.btn:active {
  transform: translateY(1px);
  box-shadow: 0 0 4px var(--glow-gold);
}
.btn-primary {
  background: var(--arcane);
  border-color: var(--gold);
  color: var(--gold-bright);
}
.btn-primary:hover {
  background: var(--violet);
  box-shadow: 0 0 16px var(--glow-arcane), 0 0 8px var(--glow-gold);
}
.btn-danger {
  border-color: var(--crimson);
  color: #f87171;
}
.btn-danger:hover {
  border-color: #ef4444;
  box-shadow: 0 0 10px var(--glow-crimson);
  text-shadow: 0 0 6px var(--crimson);
}
.btn-ok {
  border-color: var(--moss);
  color: #86efac;
}
.btn-ok:hover {
  border-color: #4ade80;
  box-shadow: 0 0 10px rgba(93,124,74,0.5);
}

/* ── Queue cards ── */
.queue-card {
  background: var(--bg-panel);
  border: 2px solid var(--gold-dim);
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
  clip-path: polygon(0 6px, 6px 6px, 6px 0, calc(100% - 6px) 0, calc(100% - 6px) 6px, 100% 6px,
                      100% calc(100% - 6px), calc(100% - 6px) calc(100% - 6px), calc(100% - 6px) 100%,
                      6px 100%, 6px calc(100% - 6px), 0 calc(100% - 6px));
  box-shadow: 0 0 0 1px var(--gold-dim), 0 4px 20px rgba(0,0,0,0.5);
}
.queue-card h3 {
  font-family: var(--font-heading);
  font-size: 24px;
  color: var(--gold-bright);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}
.queue-card .meta {
  font-family: var(--font-accent);
  font-size: 19px;
  color: var(--ink-muted);
  font-style: italic;
  margin-bottom: 10px;
}

/* ── Keyframe images ── */
.kf { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.kf img {
  max-width: 120px; max-height: 80px;
  object-fit: cover;
  border: 2px solid var(--gold-dim);
  opacity: 0.8;
  transition: opacity 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.kf img:hover {
  opacity: 1;
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--glow-gold);
}

/* ── Details / Disclosure ── */
details {
  margin: 8px 0;
  border: 1px solid var(--arcane);
  background: rgba(0,0,0,0.3);
}
details summary {
  font-family: var(--font-heading);
  font-size: 19px;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
details summary::before {
  content: '▶';
  font-size: 15px;
  color: var(--gold);
  transition: transform 0.2s;
}
details[open] summary::before { transform: rotate(90deg); }
details[open] summary { color: var(--gold-bright); }
details > *:not(summary) {
  padding: 10px 12px;
  border-top: 1px solid var(--arcane);
}

.transcript, .extraction {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--ink-muted);
  background: rgba(0,0,0,0.4);
  padding: 10px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
  line-height: 1.5;
  border: none;
  margin: 0;
  border-radius: 0;
}

/* ── Actions row ── */
.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.actions a {
  font-family: var(--font-heading);
  font-size: 18px;
  color: var(--arcane);
  text-decoration: none;
  letter-spacing: 0.05em;
  padding: 6px 10px;
  border: 1px solid var(--arcane);
  transition: all 0.15s;
}
.actions a:hover {
  color: var(--gold-bright);
  border-color: var(--gold);
  text-shadow: 0 0 6px var(--glow-gold);
}

/* ── Form elements ── */
input[type="text"],
input[type="search"],
select,
textarea {
  font-family: var(--font-body);
  font-size: 22px;
  color: var(--ink);
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--arcane);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--glow-gold);
}
input::placeholder { color: var(--ink-muted); font-style: italic; }
label {
  font-family: var(--font-heading);
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  display: block;
  margin-bottom: 4px;
}

/* ── Fieldset ── */
fieldset {
  border: 1px solid var(--gold-dim);
  padding: 10px 12px;
  margin-bottom: 12px;
  background: rgba(0,0,0,0.2);
}
fieldset legend {
  font-family: var(--font-heading);
  font-size: 16px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  padding: 0 6px;
}
fieldset label {
  font-family: var(--font-accent);
  font-size: 21px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  cursor: pointer;
}
fieldset input[type="checkbox"] {
  accent-color: var(--gold);
  width: 14px;
  height: 14px;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  font-family: var(--font-accent);
  font-size: 27px;
  font-style: italic;
  color: var(--ink-muted);
}
.empty-state::before {
  content: '🜲';
  display: block;
  font-size: 72px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* ── Back link ── */
.back-link {
  font-family: var(--font-heading);
  font-size: 19px;
  color: var(--arcane);
  text-decoration: none;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  border: 1px solid var(--arcane);
  display: inline-block;
  transition: all 0.15s;
}
.back-link:hover {
  color: var(--gold-bright);
  border-color: var(--gold);
  text-shadow: 0 0 6px var(--glow-gold);
}

/* ── Glow animation ── */
@keyframes goldFlicker {
  0%, 100% { opacity: 1; text-shadow: 0 0 8px var(--gold), 0 0 16px var(--glow-gold); }
  50%       { opacity: 0.92; text-shadow: 0 0 4px var(--gold), 0 0 8px var(--glow-gold); }
}
@keyframes emberPulse {
  0%, 100% { box-shadow: 0 0 6px var(--ember), 0 0 12px rgba(212,102,31,0.4); }
  50%       { box-shadow: 0 0 12px var(--ember), 0 0 24px rgba(212,102,31,0.6); }
}
.glow-animate { animation: goldFlicker 3s ease-in-out infinite; }
.ember-animate { animation: emberPulse 2s ease-in-out infinite; }

/* ── Scanlines overlay ── */
.scanlines {
  position: relative;
}
.scanlines::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 3px
  );
  pointer-events: none;
  z-index: 9998;
}

/* ── Content sections ── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* Graph page uses <main> as flex canvas — neutralize the default main styling */
main.graph-canvas {
  max-width: none;
  margin: 0;
  padding: 0;
}

h1 { font-family: var(--font-title); font-size: 48px; color: var(--gold-bright); text-shadow: 0 0 10px var(--gold), 0 0 20px var(--glow-gold); margin-bottom: 20px; }
h2 { font-family: var(--font-heading); font-size: 30px; color: var(--gold); letter-spacing: 0.06em; margin-bottom: 16px; border-bottom: 1px solid var(--gold-dim); padding-bottom: 6px; }
h3 { font-family: var(--font-heading); font-size: 22px; color: var(--ink); letter-spacing: 0.05em; margin-bottom: 10px; }
h4 { font-family: var(--font-accent); font-size: 21px; color: var(--gold); font-style: italic; margin-bottom: 8px; }

/* ── Utilities ── */
.text-muted { color: var(--ink-muted); }
.text-gold   { color: var(--gold-bright); }
.text-crimson { color: #f87171; }
.text-arcane  { color: #a78bfa; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
