html {
  scroll-behavior: smooth;
}

:root {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  
  /* Black & Gold Luxury Palette matching New Hair Institute Branding */
  --gold-primary: #d4af37;
  --gold-dark: #aa7c11;
  --gold-light: #fef08a;
  --gold-gradient: linear-gradient(135deg, #d4af37, #aa7c11);
  --navy-dark: #0b0f17;
  --surface-dark: #111827;
  
  --emerald-accent: #10b981;
  --amber-accent: #f59e0b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 25px -3px rgba(11, 15, 23, 0.1);
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

html.dark {
  --bg-primary: #030712;
  --bg-surface: #0b0f17;
  --bg-subtle: #111827;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-color: #1f2937;
}

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

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

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header & Navbar */
.top-strip {
  background: var(--navy-dark);
  color: #94a3b8;
  font-size: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #1f2937;
}

.top-strip .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-strip a {
  color: #cbd5e1;
  transition: color 0.2s;
}

.top-strip a:hover {
  color: var(--gold-primary);
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 5.5rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo img.main-logo-img {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.nav-links {
  display: flex;
  gap: 1.75rem;
  align-items: center;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.2s;
  position: relative;
  padding: 0.25rem 0;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: var(--gold-gradient);
  transition: width 0.2s ease;
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}

.actions-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  border-color: var(--gold-primary);
  color: var(--gold-dark);
}

/* Breadcrumbs */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

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

.breadcrumb a:hover {
  color: var(--gold-primary);
}

.breadcrumb span.sep {
  color: var(--border-color);
}

/* Typography & Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  color: var(--text-primary);
}

/* Cards & Layout Grid */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.article-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 1.25rem;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.article-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--gold-primary);
}

.card-img-wrapper {
  position: relative;
  width: 100%;
  height: 12rem;
  overflow: hidden;
  background: var(--bg-subtle);
}

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

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

.card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-grow: 1;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.card-excerpt {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 2rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-gold {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-dark);
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.badge-emerald {
  background: #d1fae5;
  color: #065f46;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--gold-gradient);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.25);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--gold-primary);
  color: var(--gold-dark);
}

/* Hero Section */
.hero-featured {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 1.5rem;
  overflow: hidden;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
  .hero-featured {
    grid-template-columns: 1fr;
  }
}

.hero-featured .card-img-wrapper {
  height: 100%;
  min-height: 20rem;
}

.hero-featured .card-body {
  padding: 2rem;
}

.hero-featured .card-title {
  font-size: 2rem;
  margin-bottom: 1rem;
}

/* Article Reader Styling (Prose) */
.prose {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.prose h2 {
  font-size: 1.75rem;
  margin: 2.2rem 0 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--gold-primary);
}

.prose h3 {
  font-size: 1.35rem;
  margin: 1.8rem 0 0.6rem;
}

.prose p {
  margin-bottom: 1.25rem;
}

.prose ul, .prose ol {
  margin: 0 0 1.5rem 1.5rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

.prose blockquote {
  border-left: 4px solid var(--gold-primary);
  background: var(--bg-subtle);
  padding: 1rem 1.5rem;
  border-radius: 0 1rem 1rem 0;
  margin: 1.5rem 0;
  font-style: italic;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.prose th, .prose td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  text-align: left;
}

.prose th {
  background: var(--bg-subtle);
  font-weight: 700;
}

/* Search Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 1.5rem;
  width: 100%;
  max-width: 640px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-input {
  flex-grow: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1.1rem;
  color: var(--text-primary);
}

/* Footer */
footer {
  background: var(--navy-dark);
  color: #cbd5e1;
  margin-top: auto;
  border-top: 1px solid #1f2937;
  padding: 3rem 0 1.5rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 1024px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

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

.footer-title {
  color: #ffffff;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.footer-links a {
  font-size: 0.85rem;
  color: #94a3b8;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--gold-primary);
}

.disclaimer-banner {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  margin-bottom: 2rem;
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.5;
}

/* Admin Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th, .admin-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.admin-table th {
  background: var(--bg-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* Global Reset & Body Protection against Mobile Horizontal Scroll */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

img {
  max-width: 100%;
  height: auto;
}

/* Mobile & Tablet Responsiveness Enhancements */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  .container {
    padding: 0 1rem;
  }

  /* Sticky Header on Mobile */
  .nav-row {
    flex-direction: column;
    height: auto;
    padding: 0.85rem 0 0.65rem 0;
    gap: 0.75rem;
    align-items: stretch;
  }

  .brand-logo {
    justify-content: center;
  }

  .brand-logo img.main-logo-img {
    height: 38px;
    max-width: 80vw;
  }

  .nav-links {
    overflow-x: auto;
    width: 100%;
    white-space: nowrap;
    padding: 0.35rem 0;
    gap: 0.75rem;
    -webkit-overflow-scrolling: touch;
    display: flex;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links a {
    font-size: 0.85rem;
    padding: 0.4rem 0.85rem;
    background: var(--bg-subtle);
    border-radius: 9999px;
    border: 1px solid var(--border-color);
  }

  .nav-links a.active {
    background: var(--navy-dark);
    color: var(--gold-primary) !important;
    border-color: var(--gold-primary);
  }

  .actions-group {
    position: absolute;
    top: 0.85rem;
    right: 1rem;
  }

  /* Prevent Mobile Safari Auto-Zoom on Input Focus */
  input[type="text"],
  input[type="email"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px !important;
  }

  /* Hero & Layout Grids Stacking */
  .hero-featured {
    grid-template-columns: 1fr !important;
    border-radius: 1.25rem;
  }

  .hero-featured .card-img-wrapper {
    min-height: 220px;
    max-height: 260px;
  }

  .hero-featured .card-title {
    font-size: 1.4rem !important;
    line-height: 1.3 !important;
  }

  main div[style*="grid-template-columns: 2.2fr 1fr"],
  main div[style*="grid-template-columns: 2.5fr 1fr"],
  main div[style*="grid-template-columns: 2.5fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 2rem !alignment;
  }

  .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }

  /* Prose Content Mobile Typography */
  .prose-content {
    font-size: 1rem !important;
    line-height: 1.75 !important;
  }

  .prose-content h2 {
    font-size: 1.4rem !important;
    margin-top: 1.75rem !important;
  }

  .prose-content h3 {
    font-size: 1.2rem !important;
  }

  /* Admin & Data Tables Mobile Scroll */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Modal Mobile Optimization */
  .modal-overlay {
    padding-top: 4vh;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .modal-content {
    border-radius: 1.25rem;
  }
}
