@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  /* Font Families */
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

  /* Raw Colors - Light Theme */
  --light-bg: #f9f9fb;
  --light-bg-card: #ffffff;
  --light-text: #111827;
  --light-text-muted: #4b5563;
  --light-border: #e5e7eb;
  --light-accent: #9d174d; /* Elegant Rose/Crimson */
  --light-accent-hover: #be185d;
  --light-accent-bg: #fdf2f8;
  --light-shadow: rgba(0, 0, 0, 0.04);
  --light-shadow-hover: rgba(0, 0, 0, 0.08);

  /* Raw Colors - Dark Theme */
  --dark-bg: #0f0f11;
  --dark-bg-card: #18181b;
  --dark-text: #f3f4f6;
  --dark-text-muted: #9ca3af;
  --dark-border: #27272a;
  --dark-accent: #fda4af; /* Light Rose */
  --dark-accent-hover: #fecdd3;
  --dark-accent-bg: #27121b;
  --dark-shadow: rgba(0, 0, 0, 0.2);
  --dark-shadow-hover: rgba(0, 0, 0, 0.3);

  /* Dynamic CSS Custom Properties */
  --bg: var(--light-bg);
  --bg-card: var(--light-bg-card);
  --text: var(--light-text);
  --text-muted: var(--light-text-muted);
  --border: var(--light-border);
  --accent: var(--light-accent);
  --accent-hover: var(--light-accent-hover);
  --accent-bg: var(--light-accent-bg);
  --shadow: var(--light-shadow);
  --shadow-hover: var(--light-shadow-hover);

  /* Automatically adapt native UI to user system preferences */
  color-scheme: light dark;
}

/* Fallback for browsers supporting prefers-color-scheme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--dark-bg);
    --bg-card: var(--dark-bg-card);
    --text: var(--dark-text);
    --text-muted: var(--dark-text-muted);
    --border: var(--dark-border);
    --accent: var(--dark-accent);
    --accent-hover: var(--dark-accent-hover);
    --accent-bg: var(--dark-accent-bg);
    --shadow: var(--dark-shadow);
    --shadow-hover: var(--dark-shadow-hover);
  }
}

/* Explicit class-based override if user pins theme */
:root[data-theme="light"] {
  --bg: var(--light-bg);
  --bg-card: var(--light-bg-card);
  --text: var(--light-text);
  --text-muted: var(--light-text-muted);
  --border: var(--light-border);
  --accent: var(--light-accent);
  --accent-hover: var(--light-accent-hover);
  --accent-bg: var(--light-accent-bg);
  --shadow: var(--light-shadow);
  --shadow-hover: var(--light-shadow-hover);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: var(--dark-bg);
  --bg-card: var(--dark-bg-card);
  --text: var(--dark-text);
  --text-muted: var(--dark-text-muted);
  --border: var(--dark-border);
  --accent: var(--dark-accent);
  --accent-hover: var(--dark-accent-hover);
  --accent-bg: var(--dark-accent-bg);
  --shadow: var(--dark-shadow);
  --shadow-hover: var(--dark-shadow-hover);
  color-scheme: dark;
}

/* Modern light-dark() CSS function support check */
@supports (color: light-dark(white, black)) {
  :root {
    --bg: light-dark(var(--light-bg), var(--dark-bg));
    --bg-card: light-dark(var(--light-bg-card), var(--dark-bg-card));
    --text: light-dark(var(--light-text), var(--dark-text));
    --text-muted: light-dark(var(--light-text-muted), var(--dark-text-muted));
    --border: light-dark(var(--light-border), var(--dark-border));
    --accent: light-dark(var(--light-accent), var(--dark-accent));
    --accent-hover: light-dark(var(--light-accent-hover), var(--dark-accent-hover));
    --accent-bg: light-dark(var(--light-accent-bg), var(--dark-accent-bg));
    --shadow: light-dark(var(--light-shadow), var(--dark-shadow));
    --shadow-hover: light-dark(var(--light-shadow-hover), var(--dark-shadow-hover));
  }
}

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

html {
  scroll-behavior: smooth;
  accent-color: var(--accent);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Container */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header & Logo Section */
header {
  padding: 40px 0 20px;
  border-bottom: 2px double var(--border);
  margin-bottom: 40px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.brand-logo {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
  transition: color 0.2s ease;
}

.brand-logo:hover {
  color: var(--accent);
}

/* Nav Links */
.nav-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

.nav-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background-color: var(--border);
  color: var(--accent);
}

.nav-link.active {
  background-color: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  background-color: var(--border);
  border-color: var(--text-muted);
}

.header-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* Main Grid Layout */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 32px;
  margin-bottom: 60px;
}

/* For homepage, let's highlight the first article */
.news-grid.has-featured > article:first-child {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 768px) {
  .news-grid.has-featured > article:first-child {
    grid-template-columns: 1.2fr 1fr;
  }
}

/* Article Card */
.article-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 6px var(--shadow);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.article-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px var(--shadow-hover);
}

.article-card:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.article-image-container {
  width: 100%;
  height: 200px;
  overflow: hidden;
  position: relative;
  background-color: var(--border);
}

.news-grid.has-featured > article:first-child .article-image-container {
  height: 100%;
  min-height: 250px;
}

.article-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

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

.article-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.article-category {
  color: var(--accent);
  background-color: var(--accent-bg);
  padding: 4px 8px;
  border-radius: 4px;
}

.article-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  line-height: 1.3;
  margin-bottom: 12px;
  color: var(--text);
  transition: color 0.2s ease;
}

.news-grid.has-featured > article:first-child .article-title {
  font-size: 2rem;
}

.article-card:hover .article-title {
  color: var(--accent);
}

.article-summary {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  flex-grow: 1;
}

.article-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.article-source {
  color: var(--text-muted);
}

.article-source-link {
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.article-source-link:hover {
  text-decoration: underline;
}

/* Detailed Page Layout */
.detail-layout {
  max-width: 740px;
  margin: 0 auto 60px;
}

.detail-header {
  margin-bottom: 32px;
}

.detail-title {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  line-height: 1.2;
  margin-bottom: 16px;
}

.detail-meta {
  display: flex;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.detail-image {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 32px;
  box-shadow: 0 4px 10px var(--shadow);
}

.detail-content {
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--text);
}

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

/* Archive List Styling */
.archive-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 60px;
}

.archive-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 2px 4px var(--shadow);
  transition: all 0.2s ease;
}

.archive-item:hover {
  transform: translateX(4px);
  border-color: var(--accent);
  box-shadow: 0 4px 8px var(--shadow-hover);
}

.archive-info h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.archive-info p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.archive-date {
  font-family: var(--font-serif);
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

/* Footer styling */
footer {
  margin-top: auto;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 12px;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--accent);
}

/* Article Relevance (Business Insight) */
.article-relevance {
  background-color: var(--accent-bg);
  border-left: 3px solid var(--accent);
  padding: 16px;
  border-radius: 0 8px 8px 0;
  margin-top: 20px;
}

.article-relevance strong {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.article-relevance p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

/* Article Use Cases */
.article-use-cases {
  margin-top: 20px;
  margin-bottom: 8px;
}

.article-use-cases strong {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.article-use-cases ul {
  padding-left: 20px;
  margin: 0;
}

.article-use-cases li {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* HTML5 Dialog Modal Overlay styling */
.insight-modal {
  border: none;
  border-radius: 16px;
  background-color: var(--bg-card);
  color: var(--text);
  max-width: 680px;
  width: 90%;
  padding: 0;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-height: 85vh;
  display: none;
}

.insight-modal[open] {
  display: flex;
  flex-direction: column;
}

/* Backdrop Overlay Styling */
.insight-modal::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

/* Modal Content Wrapper */
.modal-content {
  display: flex;
  flex-direction: column;
  position: relative;
  max-height: 85vh;
  padding: 32px;
}

/* Absolute Positioned Close Cross */
.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  font-size: 2.2rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
}

.modal-close-btn:hover {
  color: var(--accent);
}

/* Modal Header Section */
.modal-header {
  margin-bottom: 24px;
  padding-right: 40px; /* Space for close button */
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  line-height: 1.3;
  margin-top: 8px;
  color: var(--text);
}

/* Modal Body (Scrollable Content) */
.modal-body {
  overflow-y: auto;
  flex-grow: 1;
  padding-right: 8px;
  margin-bottom: 24px;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 10px;
}

.modal-summary {
  background-color: var(--bg);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.modal-summary strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-summary p {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Modal Footer Section */
.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Responsive Overrides */
@media (max-width: 640px) {
  header {
    padding: 24px 0 16px;
  }
  
  .brand-logo {
    font-size: 1.8rem;
  }
  
  .detail-title {
    font-size: 2rem;
  }
  
  .archive-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .insight-modal {
    width: 95%;
    max-height: 90vh;
  }

  .modal-content {
    padding: 24px;
  }

  .modal-title {
    font-size: 1.4rem;
  }

  .modal-close-btn {
    top: 16px;
    right: 16px;
  }

  .modal-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

}
