/* MATURE X - Chia sẻ câu chuyện & QR Code Styles */

.stories-hero {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  padding: 48px 6% 36px;
  text-align: center;
}

.stories-hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.stories-hero h1 {
  font-size: clamp(2.4rem, 4.5vw, 4rem);
  line-height: 1.1;
  margin: 0 0 16px;
  color: var(--ink);
}

.stories-hero h1 em {
  color: var(--wine);
}

.stories-hero p.lead {
  font-size: 1.125rem;
  line-height: 1.7;
  color: #6c6057;
  max-width: 680px;
  margin: 0 auto 28px;
}

.stories-tabs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  border-color: var(--wine);
  color: var(--wine);
}

.tab-btn.active {
  background: var(--wine);
  color: #fff;
  border-color: var(--wine);
  box-shadow: 0 4px 14px rgba(129, 60, 78, 0.2);
}

/* Story Form Section */
.story-form-card {
  max-width: 820px;
  margin: 0 auto 60px;
  background: #fffdfb;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(24px, 5vw, 44px);
  box-shadow: 0 10px 32px rgba(97, 69, 44, 0.06);
}

.form-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
  margin-bottom: 28px;
}

.form-header h2 {
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  margin-bottom: 8px;
}

.form-header p {
  color: #7a6a5d;
  font-size: 0.9375rem;
}

.form-group {
  margin-bottom: 22px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 8px;
  color: var(--ink);
}

.form-group label .req {
  color: var(--wine);
}

.form-group label .opt {
  font-weight: 400;
  color: #8c7b6f;
  font-size: 0.8125rem;
  margin-left: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--wine);
  box-shadow: 0 0 0 3px rgba(129, 60, 78, 0.15);
}

.form-textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

.form-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: #8c7b6f;
  margin-top: 6px;
}

/* Theme Pills Selector */
.theme-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.theme-pill-label {
  cursor: pointer;
}

.theme-pill-label input {
  display: none;
}

.theme-pill-label span {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.875rem;
  background: #fbf8f5;
  color: #6c5a4d;
  transition: all 0.2s;
}

.theme-pill-label input:checked + span {
  background: #f3e5e8;
  border-color: var(--wine);
  color: var(--wine);
  font-weight: 600;
}

/* Photo Uploader Dropzone */
.photo-uploader {
  border: 2px dashed #d9cbc0;
  border-radius: 12px;
  padding: 26px 20px;
  text-align: center;
  background: #faf6f2;
  cursor: pointer;
  transition: all 0.2s;
}

.photo-uploader:hover,
.photo-uploader.dragover {
  border-color: var(--wine);
  background: #fdf5f5;
}

.photo-uploader svg {
  margin: 0 auto 10px;
  color: var(--wine);
}

.photo-uploader p {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.9375rem;
  margin: 0 0 4px;
}

.photo-uploader small {
  color: #8c7b6f;
  font-size: 0.8125rem;
  display: block;
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.photo-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f0ebe4;
}

.photo-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.photo-preview-remove:hover {
  background: #d32f2f;
}

/* Status message */
.form-status {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9375rem;
  margin-bottom: 16px;
  display: none;
}

.form-status.error {
  display: block;
  background: #fdf0f0;
  color: #c5221f;
  border: 1px solid #f6c0be;
}

.form-status.success {
  display: block;
  background: #e6f4ea;
  color: #137333;
  border: 1px solid #ceead6;
}

/* Submit row */
.form-submit-row {
  margin-top: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.submit-story-btn {
  background: var(--wine);
  color: #fff;
  border: none;
  padding: 14px 32px;
  border-radius: 999px;
  font-size: 1.0625rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(129, 60, 78, 0.25);
}

.submit-story-btn:hover {
  background: var(--wine-dark);
  transform: translateY(-1px);
}

.submit-story-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Success Modal & QR Display Card */
.qr-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 15, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.qr-modal.active {
  display: flex;
}

.qr-card {
  background: #fffdfb;
  border-radius: 20px;
  max-width: 520px;
  width: 100%;
  padding: 32px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(45, 30, 20, 0.25);
  text-align: center;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.qr-card-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  font-size: 26px;
  color: #8c7b6f;
  cursor: pointer;
  line-height: 1;
}

.qr-badge {
  display: inline-block;
  background: #f6e6ea;
  color: var(--wine);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.qr-card h2 {
  font-size: 1.8rem;
  margin-bottom: 10px;
}

.qr-card p.subtitle {
  color: #6c5a4d;
  font-size: 0.9375rem;
  margin-bottom: 20px;
}

.qr-canvas-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: inline-block;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
  margin-bottom: 18px;
}

.qr-canvas-box canvas {
  display: block;
  max-width: 220px;
  max-height: 220px;
  width: 100%;
  height: auto;
}

.uid-box {
  background: #f6f1eb;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: monospace;
  font-size: 0.875rem;
  color: #5d4e43;
  margin-bottom: 20px;
  word-break: break-all;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.uid-copy-btn {
  background: var(--wine);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.uid-copy-btn:hover {
  background: var(--wine-dark);
}

.qr-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 480px) {
  .qr-actions {
    grid-template-columns: 1fr;
  }
}

.qr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.qr-btn.primary {
  background: var(--wine);
  color: #fff;
  border: 1px solid var(--wine);
}

.qr-btn.primary:hover {
  background: var(--wine-dark);
}

.qr-btn.secondary {
  background: #fff;
  color: var(--wine);
  border: 1.5px solid var(--wine);
}

.qr-btn.secondary:hover {
  background: #f9f0f2;
}

/* Detail Story View */
.story-detail-card {
  max-width: 860px;
  margin: 0 auto 60px;
  background: #fffdfb;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(24px, 5vw, 54px);
  box-shadow: 0 12px 40px rgba(80, 55, 35, 0.07);
}

.detail-nav-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--wine);
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 24px;
}

.detail-nav-back:hover {
  text-decoration: underline;
}

.detail-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
  margin-bottom: 32px;
}

.detail-header .theme-tag {
  display: inline-block;
  background: #f6e6ea;
  color: var(--wine);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.detail-header h1 {
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  line-height: 1.15;
  margin: 0 0 16px;
  color: var(--ink);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: #7b6a5e;
  font-size: 0.9375rem;
}

.detail-meta span strong {
  color: var(--ink);
}

/* Memorial Gallery */
.detail-gallery {
  margin: 28px 0 36px;
}

.detail-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.gallery-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: pointer;
  background: #f7f3ee;
  aspect-ratio: 4 / 3;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover img {
  transform: scale(1.04);
}

.gallery-item .zoom-hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
}

/* Detail Story Content */
.detail-content {
  font-size: 1.1875rem;
  line-height: 1.85;
  color: #3b3530;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 40px;
}

.detail-content p {
  margin-bottom: 18px;
}

/* Story QR Footer Box */
.story-qr-box {
  background: #fbf7f3;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: center;
  margin-top: 36px;
}

@media (max-width: 680px) {
  .story-qr-box {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .story-qr-box .qr-canvas-box {
    margin: 0 auto;
  }
}

.story-qr-box h3 {
  font-size: 1.35rem;
  margin-bottom: 6px;
}

.story-qr-box p {
  font-size: 0.9375rem;
  color: #6e5e52;
  margin-bottom: 16px;
}

.story-qr-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 680px) {
  .story-qr-buttons {
    justify-content: center;
  }
}

/* Lightbox Modal */
.lightbox-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 10, 8, 0.92);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox-modal.active {
  display: flex;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  line-height: 1;
}

/* Stories Grid (Community / Recent Stories) */
.stories-grid-section {
  max-width: 1280px;
  margin: 0 auto 70px;
  padding: 0 6%;
}

.stories-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.stories-search-box {
  display: flex;
  gap: 8px;
  max-width: 380px;
  width: 100%;
}

.stories-search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 0.9375rem;
}

.stories-search-btn {
  background: var(--wine);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

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

.story-card {
  background: #fffdfb;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
}

.story-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(97, 69, 44, 0.08);
}

.story-card-cover {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #f2ebe3;
}

.story-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.story-card-theme {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--wine);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.story-card h3 {
  font-size: 1.35rem;
  line-height: 1.25;
  margin: 0 0 8px;
  color: var(--ink);
}

.story-card-byline {
  font-size: 0.8125rem;
  color: #8c7b6f;
  margin-bottom: 12px;
}

.story-card-excerpt {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #615349;
  flex: 1;
  margin-bottom: 16px;
}

.story-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 0.8125rem;
  color: var(--wine);
  font-weight: 600;
}

.empty-stories {
  text-align: center;
  padding: 50px 20px;
  background: #fffdfb;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: #7b6a5e;
}

.empty-stories p {
  font-size: 1.0625rem;
  margin-bottom: 16px;
}

/* Card Template Selector in Story Form */
.card-select-group {
  background: #fdfaf6;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-top: 10px;
}

.card-select-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-select-header label {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.field-desc {
  font-size: 0.8125rem;
  color: #7a6a5d;
  margin: 0;
}

.selected-card-badge {
  display: inline-flex;
  align-items: center;
  background: #f6e6ea;
  color: var(--wine);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid rgba(129, 60, 78, 0.2);
}

.card-template-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.card-template-option {
  position: relative;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.card-template-option:hover {
  border-color: var(--wine);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(80, 50, 40, 0.08);
}

.card-template-option:focus-visible {
  outline: 2px solid var(--wine);
  outline-offset: 2px;
}

.card-template-option.selected {
  border-color: var(--wine);
  background: #fdf8f9;
  box-shadow: 0 4px 14px rgba(129, 60, 78, 0.18);
}

.card-template-option .card-swatch {
  height: 50px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  margin-bottom: 2px;
}

.card-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-option-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-option-title-row strong {
  font-size: 0.875rem;
  color: var(--ink);
  line-height: 1.3;
}

.card-check-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--wine);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-template-option.selected .card-check-icon {
  opacity: 1;
  transform: scale(1);
}

.card-option-info small {
  font-size: 0.75rem;
  color: #7a6a5d;
  line-height: 1.3;
}

/* Form Live Card Preview */
.form-card-live-preview {
  margin-top: 20px;
  background: #fffdfa;
  border: 1.5px dashed #ded3c5;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
}

.form-card-preview-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.preview-title-area {
  text-align: left;
}

.preview-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--wine);
  letter-spacing: 0.5px;
  display: block;
}

.preview-title-area h4 {
  font-size: 1.05rem;
  margin: 2px 0 0;
  color: var(--ink);
}

.preview-badge-status {
  font-size: 0.8125rem;
  color: #8c7b6f;
  font-style: italic;
}

.pattern-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8125rem;
  color: var(--ink);
  cursor: pointer;
  background: #fff;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  transition: all 0.2s ease;
  user-select: none;
}

.pattern-toggle-label:hover {
  border-color: var(--wine);
  background: #fdf8f9;
}

.pattern-toggle-label input[type="checkbox"] {
  accent-color: var(--wine);
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
}

.form-card-canvas-wrap {
  display: inline-block;
  max-width: 320px;
  width: 100%;
  margin: 6px auto 10px;
}

.form-card-canvas {
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(45, 30, 20, 0.12);
  display: block;
}

.form-card-preview-hint {
  font-size: 0.8125rem;
  color: #8c7b6f;
  margin: 0;
  font-style: italic;
}

/* Rendered Keepsake Card Section in Story Detail */
.story-card-render-section {
  background: #fbf7f3;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(24px, 4vw, 40px);
  margin-top: 40px;
  text-align: center;
}

/* Detail Card Switcher Bar */
.detail-card-switcher-box {
  margin: 20px auto 24px;
  max-width: 680px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.detail-switcher-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.9375rem;
  color: var(--ink);
  flex-wrap: wrap;
}

.detail-switcher-note {
  font-size: 0.8125rem;
  color: #8c7b6f;
}

.detail-card-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.detail-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.detail-switch-btn:hover {
  border-color: var(--wine);
  color: var(--wine);
  transform: translateY(-1px);
}

.detail-switch-btn.active {
  background: #fdf5f6;
  border-color: var(--wine);
  color: var(--wine);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(129, 60, 78, 0.15);
}

.detail-switch-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.rendered-card-wrapper {
  display: inline-block;
  max-width: 500px;
  width: 100%;
  margin: 10px auto 24px;
}

.rendered-card-canvas {
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(45, 30, 20, 0.14);
  display: block;
}
