/* ═══════════════════════════════════════
   STORIED FLAVOURS — Stories
   ═══════════════════════════════════════ */

.stories-page {
  position: relative;
}

.stories-page::before {
  content: '';
  position: fixed;
  top: var(--topbar-height);
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  background: url('../assets/stories-bg.png') center / cover no-repeat;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

.stories-page > * {
  position: relative;
  z-index: 1;
}

.stories-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.stories-header h1 { font-size: var(--font-size-3xl); }

.stories-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.stories-toolbar .search-box { flex: 1; min-width: 240px; }

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-5);
}

.story-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.story-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 20px rgba(200, 90, 31, 0.22), 0 0 0 1.5px rgba(200, 90, 31, 0.18);
}

/* Story detail */
.story-detail { max-width: 760px; margin: 0 auto; }

.story-hero {
  position: relative;
  height: 280px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  margin-bottom: var(--space-8);
}

.story-title {
  font-size: var(--font-size-4xl);
  margin-bottom: var(--space-3);
}

.story-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

.story-content {
  font-size: var(--font-size-lg);
  line-height: 1.9;
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
  white-space: pre-line;
}

.story-linked {
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-8);
}

.story-linked h3 {
  font-size: var(--font-size-base);
  margin-bottom: var(--space-4);
}

.story-linked-items {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.story-linked-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-amber-light);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-amber-dark);
}

.story-linked-item:hover {
  background: var(--color-amber);
  color: white;
}

/* Add story */
.story-add-page {
  max-width: 700px;
  margin: 0 auto;
  position: relative;
}

.story-add-page--family::before,
.story-add-page--circle::before {
  content: '';
  position: fixed;
  top: var(--topbar-height);
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.story-add-page--family::before,
.story-add-page--circle::before  { background-image: url('../assets/story-add-bg.png'); }

.story-add-page--family > *,
.story-add-page--circle > * {
  position: relative;
  z-index: 1;
}

.story-add-page h1 {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-2);
}

.story-add-page > p {
  color: var(--text-muted);
  margin-bottom: var(--space-8);
}

/* ── Story Gallery ───────────────────────────────────────────────────────── */

.story-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.story-gallery-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-card);
  border: 1px solid var(--border-light);
}

.story-gallery-img-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
}

.story-gallery-img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.story-gallery-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  gap: var(--space-2);
  background: var(--surface-page);
  border-top: 1px solid var(--border-light);
}

.story-gallery-order-btns {
  display: flex;
  gap: var(--space-1);
}

.story-gallery-caption {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  background: var(--surface-card);
  border-top: 1px solid var(--border-light);
}

.gallery-caption-text {
  cursor: text;
  display: block;
  min-height: 1.2em;
}

.gallery-caption-text:hover { color: var(--color-amber-dark); }

.gallery-caption-input {
  width: 100%;
  font-size: var(--font-size-xs);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-amber);
  border-radius: var(--radius-sm);
  background: var(--surface-input);
  color: var(--text-primary);
  box-sizing: border-box;
}

/* ── Story Lightbox ──────────────────────────────────────────────────────── */

.story-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.story-lightbox-close {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  background: rgba(255,255,255,0.12);
  border: none;
  color: white;
  font-size: 1.75rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-lightbox-close:hover { background: rgba(255,255,255,0.22); }

.story-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.12);
  border: none;
  color: white;
  font-size: 2rem;
  line-height: 1;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-lightbox-nav:hover { background: rgba(255,255,255,0.22); }
.story-lightbox-nav--prev { left: var(--space-5); }
.story-lightbox-nav--next { right: var(--space-5); }

.story-lightbox-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(900px, 90vw);
  max-height: 90vh;
}

.story-lightbox-img {
  max-width: 100%;
  max-height: calc(90vh - 60px);
  object-fit: contain;
  border-radius: var(--radius-md);
}

.story-lightbox-caption {
  color: rgba(255,255,255,0.7);
  font-size: var(--font-size-sm);
  margin-top: var(--space-3);
  text-align: center;
}

/* ── Photo count badge on story cards ───────────────────────────────────── */

.story-card-photo-count {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .story-hero { height: 180px; font-size: 56px; }
  .story-title { font-size: var(--font-size-2xl); }
  .story-content { font-size: var(--font-size-base); }
}
