/* ================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   ================================ */
:root {
  --bg-primary: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  --bg-card: #fff;
  --bg-footer: #f8f9fa;
  --bg-card-footer: #f9f9f9;
  --text-primary: #333;
  --text-secondary: #555;
  --text-tertiary: #777;
  --text-muted: #666;
  --text-bold: #1a1a1a;
  --border-color: #eee;
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-medium: rgba(0, 0, 0, 0.15);
  --hero-gradient: linear-gradient(120deg, #d84800 0%, #f05d1f 100%);
  --pattern-bg: #888;
  --pattern-overlay: #e5e5f7;
}

[data-theme="dark"],
:root:not([data-theme="light"]) {
  --bg-primary: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  --bg-card: #2a2a2a;
  --bg-footer: #1a1a1a;
  --bg-card-footer: #242424;
  --text-primary: #e0e0e0;
  --text-secondary: #c0c0c0;
  --text-tertiary: #a0a0a0;
  --text-muted: #888;
  --text-bold: #f5f5f5;
  --border-color: #404040;
  --shadow-light: rgba(0, 0, 0, 0.3);
  --shadow-medium: rgba(0, 0, 0, 0.4);
  --pattern-bg: #404040;
  --pattern-overlay: #1e1e1e;
}

/* Dark mode title overrides */
[data-theme="dark"] .hero .title,
[data-theme="dark"] .summary-hero .title,
[data-theme="dark"] .summary-title,
:root:not([data-theme="light"]) .hero .title,
:root:not([data-theme="light"]) .summary-hero .title,
:root:not([data-theme="light"]) .summary-title {
  color: rgba(255, 255, 255, 0.8) !important;
}

[data-theme="dark"] .hero .subtitle,
[data-theme="dark"] .summary-hero .subtitle,
:root:not([data-theme="light"]) .hero .subtitle,
:root:not([data-theme="light"]) .summary-hero .subtitle {
  color: rgba(255, 255, 255, 0.6) !important;
}

/* Dark mode main tabs */
[data-theme="dark"] .main-tabs .button,
:root:not([data-theme="light"]) .main-tabs .button {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .main-tabs .button:hover,
:root:not([data-theme="light"]) .main-tabs .button:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

[data-theme="dark"] .main-tabs .button.is-primary,
:root:not([data-theme="light"]) .main-tabs .button.is-primary {
  background: rgba(255, 255, 255, 0.9);
  color: #d84800;
}

[data-theme="dark"] .main-tabs .button.is-primary:hover,
:root:not([data-theme="light"]) .main-tabs .button.is-primary:hover {
  background: white;
  color: #d84800;
}

/* ================================
   BASE STYLES
   ================================ */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

a {
  color: #d84800;
}
a:hover {
  color: #b83d00;
}

.title {
  color: #d84800;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
}

/* ================================
   HERO SECTIONS
   ================================ */
.hero {
  background: var(--hero-gradient);
  color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.hero .title {
  color: white !important;
  font-weight: 700;
}

.hero .title a {
  color: white !important;
  text-decoration: none;
  transition: color 0.2s ease;
}

.hero .title a:hover {
  color: rgba(255, 255, 255, 0.9) !important;
}

.hero .subtitle {
  color: rgba(255, 255, 255, 0.9) !important;
}

/* Main tabs styling in hero section */
.main-tabs .button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  transition: all 0.3s ease;
}

.main-tabs .button:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  transform: translateY(-2px);
}

.main-tabs .button.is-primary {
  background: rgba(255, 255, 255, 0.9);
  color: #d84800;
  border-color: rgba(255, 255, 255, 0.9);
}

.main-tabs .button.is-primary:hover {
  background: white;
  color: #d84800;
  transform: translateY(-2px);
}

.summary-hero {
  background: var(--hero-gradient);
  color: white;
  position: relative;
  overflow: hidden;
}

.summary-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
  background-size: 20px 20px;
  opacity: 0.3;
}

.summary-title {
  color: white !important;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  font-size: 2rem;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.summary-title a {
  color: white !important;
  text-decoration: none;
  transition: color 0.2s ease;
}

.summary-title a:hover {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: underline;
}

.summary-hero .subtitle a {
  color: rgba(255, 255, 255, 0.9) !important;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.5);
  transition: all 0.3s ease;
}

.summary-hero .subtitle a:hover {
  color: white !important;
  border-bottom: 1px solid white;
  background-color: rgba(255, 255, 255, 0.1);
}

.back-button {
  display: inline-flex;
  align-items: center;
  color: white !important;
  transition: color 0.3s ease;
}

.back-button:hover {
  color: rgba(255, 255, 255, 0.8) !important;
}

/* ================================
   PATTERN SECTION
   ================================ */
.section {
  padding: 1.5rem;
  background-color: var(--pattern-overlay);
  opacity: 0.8;
  background-size: 4px 4px;
  background-image: repeating-linear-gradient(135deg, var(--pattern-bg) 0, var(--pattern-bg) 0.6px, var(--pattern-overlay) 0, var(--pattern-overlay) 50%);
}

/* ================================
   CARDS & CONTENT
   ================================ */
.card {
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
  border: none;
  background: var(--bg-card);
  color: var(--text-primary);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}

.card-content .title a {
  color: var(--text-primary);
  transition: color 0.2s ease;
}

.card-content .title a:hover {
  color: #d84800;
  text-decoration: none;
}

.card-content .subtitle {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.card-image {
  height: 180px;
  background-color: var(--bg-card-footer);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  overflow: hidden;
}

.card-image::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.4) 100%);
  pointer-events: none;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transition: transform 0.3s ease;
}

.card:hover .card-image img {
  transform: scale(1.05);
}

.card-footer {
  background-color: var(--bg-card-footer);
  border-top: 1px solid var(--border-color);
}

.card-footer-item {
  color: var(--text-muted);
  transition: color 0.2s ease, background-color 0.2s ease;
}

.card-footer-item:hover {
  background-color: var(--bg-card-footer);
  color: #d84800;
}

/* ================================
   IMAGE PLACEHOLDER
   ================================ */
.image-placeholder {
  width: 100%;
  height: 100%;
  background: var(--hero-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  text-align: center;
  padding: 1rem;
  word-break: break-word;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.image-placeholder i.fa-fire {
  font-size: 2.5rem;
  display: block;
  line-height: 1;
}

/* ================================
   STORY COMPONENTS
   ================================ */
.buttons.story-filters {
  flex-wrap: nowrap;
}

.story-filters .button {
  min-width: 80px;
  border-radius: 4px;
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.story-filters .button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.story-filters .button.is-primary {
  background-color: #d84800;
}

.story-filters .button.is-primary:hover {
  background-color: #b83d00;
}

.story-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.story-card {
  display: flex;
  background: var(--bg-card);
  border-radius: 8px;
  box-shadow: 0 2px 4px var(--shadow-light);
  min-height: 140px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid var(--border-color);
}

.story-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow-medium);
}

.story-image {
  width: 140px;
  min-height: 140px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.story-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.story-content {
  flex: 1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.story-content .title a {
  color: var(--text-primary);
}

.story-content .subtitle {
  color: var(--text-tertiary);
}

.story-actions .button {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 4px;
  background-color: var(--bg-card-footer);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.story-actions .button:hover {
  background-color: #d84800;
  color: white;
  border-color: #d84800;
}

/* ================================
   SUMMARY COMPONENTS
   ================================ */
.summary-card {
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.summary-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* ================================
   MARKDOWN CONTENT
   ================================ */
.markdown-body,
.markdown-body p,
.markdown-body li {
  font-size: 1.2rem !important;
  line-height: 1.7 !important;
  color: var(--text-primary) !important;
}

.markdown-body {
  background-color: transparent !important;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-weight: 600;
  color: var(--text-primary) !important;
}

.markdown-body blockquote {
  border-left: 4px solid #d84800;
  background-color: var(--bg-card-footer);
  color: var(--text-secondary);
}

.markdown-body code {
  background-color: var(--bg-card-footer);
  color: var(--text-primary);
}

.markdown-body pre {
  background-color: var(--bg-card-footer) !important;
  border: 1px solid var(--border-color);
}

.markdown-body strong,
.markdown-body b {
  color: var(--text-bold) !important;
  font-weight: 700 !important;
}

/* ================================
   BULMA OVERRIDES
   ================================ */
.box {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.box:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content h6 {
  color: var(--text-primary) !important;
}

.content,
.content p {
  color: var(--text-primary);
}

.content a {
  color: #d84800;
}

.content a:hover {
  color: #b83d00;
}

.summary-content .title,
.box .title,
.content .title {
  color: var(--text-primary) !important;
}

.button {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.button:hover {
  background-color: var(--bg-card-footer);
}

.button.is-primary {
  background-color: #d84800;
  color: white;
}

.button.is-primary:hover {
  background-color: #b83d00;
}

input,
textarea,
select {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

input:focus,
textarea:focus,
select:focus {
  border-color: #d84800;
  box-shadow: 0 0 0 0.125em rgba(216, 72, 0, 0.25);
}

.notification.is-warning {
  background-color: #ffeaa7;
  color: #2d3436;
}

[data-theme="dark"] .notification.is-warning,
:root:not([data-theme="light"]) .notification.is-warning {
  background-color: #8b7a00;
  color: #fff3cd;
}

.footer {
  font-size: 0.8rem;
  background-color: var(--bg-footer);
  padding: 0.6rem;
  border-top: 1px solid var(--border-color);
}

.footer a {
  color: #d84800;
}

/* ================================
   DARK MODE TOGGLE
   ================================ */
.dark-mode-toggle {
  position: absolute !important;
  top: 20px !important;
  right: 20px !important;
  z-index: 99999 !important;
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  padding: 8px 12px !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 2px 8px var(--shadow-light) !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  -webkit-tap-highlight-color: transparent !important;
  touch-action: manipulation !important;
  display: inline-block !important;
}

.dark-mode-toggle:hover {
  background: var(--bg-card-footer);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow-medium);
}

/* ================================
   UTILITIES
   ================================ */
.loader-container {
  display: flex;
  justify-content: center;
  margin: 2rem;
}

.loader {
  border-color: #d84800 transparent transparent transparent;
}

/* ================================
   RESPONSIVE DESIGN
   ================================ */
@media (max-width: 767px) {
  .markdown-body,
  .markdown-body p,
  .markdown-body li {
    font-size: 1rem;
    line-height: 1.6;
  }

  .story-card {
    flex-direction: column;
    height: auto;
  }

  .story-image {
    width: 100%;
    height: 160px;
  }

  .summary-title {
    font-size: 1.5rem;
  }

  .dark-mode-toggle {
    top: 15px !important;
    right: 15px !important;
    padding: 10px !important;
    font-size: 1rem !important;
    border-radius: 50% !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transform: none !important;
  }

  .dark-mode-toggle:hover {
    transform: translateY(-1px);
  }
}

@media (max-width: 1024px) and (min-width: 769px) {
  .dark-mode-toggle {
    top: 18px !important;
    right: 18px !important;
    padding: 10px 12px !important;
    font-size: 1rem !important;
    border-radius: 6px !important;
    transform: none !important;
  }

  .dark-mode-toggle:hover {
    transform: translateY(-1px);
  }
}
