/* ═══════════════════════════════════════════════════════
   Poe's Gothic Library — Shared Stylesheet
   ═══════════════════════════════════════════════════════ */

@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;1,500;1,600;1,700&family=Cinzel+Decorative:wght@400;700&display=swap');

/* ── Reset & Base ──────────────────────────────────── */

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

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Cormorant Garamond', 'Georgia', serif;
  font-weight: 400;
  background-color: #0d0d0f;
  color: #c8c0b4;
  line-height: 1.85;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Texture Overlay ──────────────────────────────── */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(45, 20, 10, 0.15) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 50%, rgba(20, 15, 40, 0.15) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════════════════
   STORY PAGE STYLES
   ═══════════════════════════════════════════════════════ */

/* ── Story Container ──────────────────────────────── */

.story {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 4rem 2rem 6rem;
}

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

.story-header {
  text-align: center;
  margin-bottom: 3.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid rgba(160, 130, 90, 0.2);
}

.story-header::after {
  content: '◆';
  display: block;
  margin-top: 1.5rem;
  color: rgba(160, 130, 90, 0.35);
  font-size: 0.7rem;
  letter-spacing: 1em;
}

.story-title {
  font-family: 'Cinzel', 'Georgia', serif;
  font-weight: 500;
  font-size: 2.4rem;
  color: #d4c5a0;
  letter-spacing: 0.04em;
  line-height: 1.25;
  margin-bottom: 0.75rem;
  text-shadow: 0 0 40px rgba(180, 150, 90, 0.08);
}

.story-subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 1.1rem;
  color: rgba(200, 192, 180, 0.5);
  letter-spacing: 0.02em;
}

.story-meta {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  color: rgba(160, 130, 90, 0.4);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 1rem;
}

/* ── Prose ─────────────────────────────────────────── */

.story p {
  font-size: 1.05rem;
  margin-bottom: 1.4rem;
  text-align: justify;
  hyphens: auto;
  text-indent: 1.5em;
}

.story p:first-of-type {
  text-indent: 0;
}

.story p:first-of-type::first-letter {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: 3.8em;
  float: left;
  line-height: 0.75;
  margin-right: 0.08em;
  margin-top: 0.1em;
  color: #d4c5a0;
  text-shadow: 0 0 20px rgba(180, 150, 90, 0.15);
}

/* ── Scene Breaks ─────────────────────────────────── */

.scene-break {
  text-align: center;
  margin: 2.5rem 0;
  color: rgba(160, 130, 90, 0.3);
  font-size: 0.8rem;
  letter-spacing: 0.5em;
}

.scene-break::before {
  content: '· · ·';
}

hr {
  border: none;
  text-align: center;
  margin: 2.5rem 0;
}

hr::before {
  content: '———';
  color: rgba(160, 130, 90, 0.25);
  letter-spacing: 0.3em;
  font-size: 0.8rem;
}

/* ── Dialogue & Emphasis ──────────────────────────── */

.story em {
  font-style: italic;
  color: #d4c8b0;
}

.story strong {
  font-weight: 600;
  color: #d4c5a0;
}

blockquote {
  border-left: 2px solid rgba(160, 130, 90, 0.25);
  margin: 2rem 0 2rem 1rem;
  padding: 0.5rem 0 0.5rem 1.5rem;
  font-style: italic;
  color: rgba(200, 192, 180, 0.7);
}

/* ── Images ───────────────────────────────────────── */

.story-image {
  margin: 2.5rem -1rem;
  text-align: center;
}

.story-image a {
  display: block;
}

.story-image img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 2px;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(160, 130, 90, 0.1);
  cursor: zoom-in;
  transition: box-shadow 0.2s ease;
}

.story-image a:hover img {
  box-shadow:
    0 4px 28px rgba(0, 0, 0, 0.65),
    0 0 80px rgba(0, 0, 0, 0.4);
}

.story-image figcaption {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  color: rgba(160, 130, 90, 0.35);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 0.8rem;
}

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

.story-end {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid rgba(160, 130, 90, 0.15);
}

.story-end .finis {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(160, 130, 90, 0.4);
}

/* ── Back Link ────────────────────────────────────── */

.back-link {
  display: inline-block;
  margin-top: 2rem;
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(160, 130, 90, 0.4);
  text-decoration: none;
  transition: color 0.3s ease;
}

.back-link:hover {
  color: rgba(160, 130, 90, 0.7);
}

.back-link::before {
  content: '← ';
}

.remix-block {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.remix-btn {
  display: inline-block;
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(160, 130, 90, 0.5);
  text-decoration: none;
  border: 1px solid rgba(160, 130, 90, 0.2);
  padding: 0.45rem 1.1rem;
  border-radius: 2px;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.remix-btn:hover {
  color: rgba(160, 130, 90, 0.85);
  border-color: rgba(160, 130, 90, 0.5);
}

/* ═══════════════════════════════════════════════════════
   INDEX PAGE STYLES
   ═══════════════════════════════════════════════════════ */

.library {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 5rem 2rem 6rem;
}

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

.library-header {
  text-align: center;
  margin-bottom: 4rem;
}

.library-title {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-weight: 400;
  font-size: 2.6rem;
  color: #d4c5a0;
  letter-spacing: 0.06em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 40px rgba(180, 150, 90, 0.1);
}

.library-subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 1.15rem;
  color: rgba(200, 192, 180, 0.45);
  margin-top: 0.75rem;
}

.library-rule {
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(160, 130, 90, 0.3), transparent);
  margin: 1.5rem auto 0;
  border: none;
}

/* ── Story List ───────────────────────────────────── */

.story-list {
  list-style: none;
}

.story-entry {
  padding: 1.8rem 0;
  border-bottom: 1px solid rgba(160, 130, 90, 0.08);
  transition: border-color 0.3s ease;
}

.story-entry:first-child {
  border-top: 1px solid rgba(160, 130, 90, 0.08);
}

.story-entry:hover {
  border-color: rgba(160, 130, 90, 0.2);
}

.story-entry a {
  text-decoration: none;
  display: block;
}

.story-entry-title {
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: 1.2rem;
  color: #d4c5a0;
  letter-spacing: 0.03em;
  margin-bottom: 0.4rem;
  transition: color 0.3s ease;
}

.story-entry a:hover .story-entry-title {
  color: #e8dbc0;
  text-shadow: 0 0 20px rgba(180, 150, 90, 0.15);
}

.story-entry-desc {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.95rem;
  color: rgba(200, 192, 180, 0.45);
  line-height: 1.5;
}

.story-entry-meta {
  font-family: 'Cinzel', serif;
  font-size: 0.55rem;
  color: rgba(160, 130, 90, 0.3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 0.5rem;
}

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

.library-footer {
  text-align: center;
  margin-top: 4rem;
  padding-top: 2rem;
}

.library-footer p {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: rgba(200, 192, 180, 0.25);
}

/* ── Library Grid ─────────────────────────────────── */

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 2rem;
  list-style: none;
  padding: 0;
}

.story-card {
  position: relative;
  border: 1px solid rgba(160,130,90,0.12);
  border-radius: 3px;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, #1a1a1f 0%, #2a2530 100%);
}
.story-card:hover {
  border-color: rgba(160,130,90,0.4);
  box-shadow: 0 0 20px rgba(160,130,90,0.08);
}

/* Reset link styles — hover effects on the card, not the text */
.story-card > a {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 2;
  text-decoration: none;
  color: inherit;
}
.story-card > a:hover,
.story-card > a:active,
.story-card > a:focus-visible {
  text-decoration: none;
  color: inherit;
  outline: none;
}

/* Full-bleed cover image as card background */
.story-card-cover {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.story-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  opacity: 0.75;
}
.story-card-cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(160,130,90,0.25);
  font-family: 'Cinzel', serif;
  font-size: 2rem;
}

/* Text overlay with gradient fade from bottom */
.story-card-body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
  padding: 3rem 1rem 1rem;
  background: linear-gradient(
    to top,
    rgba(13,13,15,0.95) 0%,
    rgba(13,13,15,0.8) 50%,
    rgba(13,13,15,0) 100%
  );
}
.story-card-title {
  font-family: 'Cinzel', serif;
  color: #d4c5a0;
  font-size: 1rem;
  margin-bottom: 0.3rem;
  line-height: 1.3;
}
.story-card-desc {
  font-style: italic;
  font-size: 0.85rem;
  color: rgba(200,192,180,0.5);
  line-height: 1.4;
}
.story-card-meta {
  font-family: 'Cinzel', serif;
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(160,130,90,0.45);
  margin-top: 0.5rem;
}

.favorite-btn {
  position: absolute; top: 0.5rem; right: 0.5rem;
  z-index: 3;
  background: rgba(0,0,0,0.5); border: none; color: rgba(160,130,90,0.4);
  font-size: 1.1rem; cursor: pointer; border-radius: 50%; width: 2rem; height: 2rem;
  transition: color 0.2s; display: flex; align-items: center; justify-content: center;
}
.favorite-btn:hover { color: rgba(160,130,90,0.7); }
.favorite-btn.active { color: #d4a050; }

.library-controls {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 2rem; gap: 1rem; flex-wrap: wrap;
}
.library-controls select, .library-controls label {
  background: #1a1a1f; border: 1px solid rgba(160,130,90,0.25);
  color: #c8c0b4; padding: 0.4rem 0.8rem; font-family: inherit; font-size: 0.85rem;
  border-radius: 2px; cursor: pointer;
}
.surprise-btn {
  font-family: 'Cinzel', serif; font-size: 0.7rem; letter-spacing: 0.1em;
  text-transform: uppercase; text-decoration: none;
  border: 1px solid rgba(160,130,90,0.35); color: rgba(160,130,90,0.6);
  padding: 0.5rem 1.2rem; transition: all 0.3s;
}
.surprise-btn:hover { border-color: rgba(160,130,90,0.6); color: rgba(160,130,90,0.9); }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  html { font-size: 16px; }
  .story { padding: 2.5rem 1.25rem 4rem; }
  .library { padding: 3rem 1.25rem 4rem; }
  .story-title { font-size: 1.8rem; }
  .library-title { font-size: 2rem; }
  .story-image { margin: 2rem 0; }
  .story-grid { gap: 1.25rem; }
  .story-card-title { font-size: 0.9rem; }
  .story-card-desc { font-size: 0.8rem; }
  .story-card-body { padding: 2.5rem 0.75rem 0.75rem; }
  .queue { padding: 3rem 1.25rem 4rem; }
  .queue-item-title { font-size: 0.85rem; padding-right: 5rem; }
  .progress-step-label { font-size: 0.45rem; }
}

/* ── Print ────────────────────────────────────────── */

@media print {
  body { background: white; color: #1a1a1a; }
  body::before { display: none; }
  .story-title, .library-title { color: #1a1a1a; }
  .back-link { display: none; }
}

/* ── Commission Form ──────────────────────────────── */

.commission {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 4rem 2rem 6rem;
}

.commission-form {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.commission-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(160,130,90,0.6);
}
.commission-form textarea,
.commission-form input,
.commission-form select {
  background: #1a1a1f;
  border: 1px solid rgba(160,130,90,0.25);
  color: #c8c0b4;
  padding: 0.7rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  border-radius: 2px;
  resize: vertical;
}
.commission-form textarea:focus,
.commission-form input:focus,
.commission-form select:focus {
  outline: none;
  border-color: rgba(160,130,90,0.5);
}

.commission-status {
  text-align: center;
  padding: 4rem 2rem;
}
.commission-status .waiting {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.2rem;
  color: rgba(200,192,180,0.5);
  margin-top: 2rem;
}
.commission-status .error-text {
  color: #c08a7a;
}

/* ── Progress Tracker ─────────────────────────────── */

.commission-progress {
  display: flex; align-items: flex-start; gap: 0;
  margin: 2rem auto; max-width: 500px; justify-content: center;
}
.progress-step {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.4rem; flex: 1;
}
.progress-step-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(160,130,90,0.2); border: 1px solid rgba(160,130,90,0.3);
  transition: all 0.4s;
}
.progress-step.active .progress-step-dot {
  background: #d4a050; box-shadow: 0 0 8px rgba(212,160,80,0.5);
}
.progress-step.done .progress-step-dot {
  background: rgba(160,130,90,0.6);
}
.progress-step-label {
  font-family: 'Cinzel', serif; font-size: 0.5rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgba(160,130,90,0.3); text-align: center;
}
.progress-step.active .progress-step-label {
  color: rgba(212,160,80,0.8);
}
.progress-step.done .progress-step-label {
  color: rgba(160,130,90,0.5);
}
.progress-connector {
  flex: 1; height: 1px; background: rgba(160,130,90,0.15); margin-top: 5px;
}

/* ── Queue View ───────────────────────────────────── */

.queue {
  position: relative; z-index: 1;
  max-width: 960px; margin: 0 auto; padding: 4rem 2rem 6rem;
}
.queue-list {
  list-style: none; padding: 0; max-width: 700px;
  margin: 0 auto; display: flex; flex-direction: column; gap: 1rem;
}
.queue-item {
  border: 1px solid rgba(160,130,90,0.12); padding: 1rem 1.2rem;
  border-radius: 2px; position: relative;
}
.queue-item:hover { border-color: rgba(160,130,90,0.25); }
.queue-item-title {
  font-family: 'Cinzel', serif; color: #d4c5a0; font-size: 0.9rem;
  margin-bottom: 0.3rem; padding-right: 6rem;
}
.queue-item-meta {
  font-size: 0.75rem; color: rgba(160,130,90,0.4);
}
.queue-item-status {
  position: absolute; top: 1rem; right: 1.2rem;
  font-family: 'Cinzel', serif; font-size: 0.6rem;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.queue-item-status.pending { color: rgba(160,130,90,0.4); }
.queue-item-status.writing { color: #d4a050; }
.queue-item-status.generating-images { color: #d4a050; }
.queue-item-status.done { color: rgba(100,180,100,0.7); }
.queue-item-status.failed { color: rgba(200,80,80,0.7); }

/* ── Story Actions ────────────────────────────────── */

.story-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

.delete-story-btn {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: none;
  border: 1px solid rgba(200,80,80,0.25);
  color: rgba(200,80,80,0.4);
  padding: 0.4rem 1rem;
  cursor: pointer;
  transition: all 0.3s;
}
.delete-story-btn:hover {
  border-color: rgba(200,80,80,0.5);
  color: rgba(200,80,80,0.7);
}

/* ── Confirmation Dialog ──────────────────────────── */

.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.confirm-dialog {
  background: #1a1a1f;
  border: 1px solid rgba(160,130,90,0.25);
  padding: 2.5rem;
  max-width: 420px;
  text-align: center;
}
.confirm-dialog h2 {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: #d4c5a0;
  margin-bottom: 1rem;
}
.confirm-dialog p {
  font-size: 0.85rem;
  color: rgba(200,192,180,0.5);
  line-height: 1.6;
  margin-bottom: 2rem;
}
.confirm-actions {
  display: flex; gap: 1rem; justify-content: center;
}
.confirm-cancel,
.confirm-danger {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  border: 1px solid rgba(160,130,90,0.25);
  background: none;
  color: rgba(160,130,90,0.6);
  transition: all 0.2s;
}
.confirm-cancel:hover {
  border-color: rgba(160,130,90,0.5);
  color: rgba(160,130,90,0.8);
}
.confirm-danger {
  border-color: rgba(200,80,80,0.3);
  color: rgba(200,80,80,0.6);
}
.confirm-danger:hover {
  border-color: rgba(200,80,80,0.6);
  color: rgba(200,80,80,0.9);
}
.confirm-danger:disabled {
  opacity: 0.4;
  cursor: default;
}
