/* =====================================================================
   THE BUSINESS TALE — CORE DESIGN SYSTEM
   main.css: Design tokens, reset, typography, layout, base utilities
   ===================================================================== */

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

/* -----------------------------------------------------------------------
   2. DESIGN TOKENS
   ----------------------------------------------------------------------- */
:root {
  /* Colors */
  --color-bg:              #fafaf8;
  --color-surface:         #ffffff;
  --color-surface-alt:     #f5f5f3;
  --color-text-primary:    #1a1a1a;
  --color-text-secondary:  #3d3d3d;
  --color-text-muted:      #767676;
  --color-accent:          #c0392b;
  --color-accent-hover:    #a93226;
  --color-accent-light:    #fdf2f1;
  --color-border:          #e5e5e0;
  --color-border-light:    #f0f0ed;
  --color-nav-bg:          #ffffff;
  --color-ad-bg:           #f2f2ef;
  --color-sponsored:       #fff8e6;
  --color-sponsored-border:#e8c96a;

  /* Typography */
  --font-serif:   'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Font sizes — fluid scale */
  --text-xs:   0.75rem;    /* 12px */
  --text-sm:   0.875rem;   /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-md:   1.125rem;   /* 18px */
  --text-lg:   1.25rem;    /* 20px */
  --text-xl:   1.5rem;     /* 24px */
  --text-2xl:  1.875rem;   /* 30px */
  --text-3xl:  2.25rem;    /* 36px */
  --text-4xl:  2.75rem;    /* 44px */
  --text-5xl:  3.5rem;     /* 56px */

  /* Line heights */
  --leading-tight:  1.2;
  --leading-snug:   1.35;
  --leading-base:   1.6;
  --leading-relaxed:1.75;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Layout */
  --container-max:     1200px;
  --container-wide:    1400px;
  --article-max:       760px;
  --sidebar-width:     300px;
  --nav-height:        64px;

  /* Borders & Radius */
  --radius-sm:  3px;
  --radius-md:  6px;
  --radius-lg:  10px;
  --border-thin: 1px solid var(--color-border);
  --border-light: 1px solid var(--color-border-light);

  /* Shadows — restrained */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:  0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg:  0 4px 16px rgba(0,0,0,0.10);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-base:   250ms ease;
  --transition-slow:   350ms ease;

  /* Z-index scale */
  --z-below:    -1;
  --z-base:      0;
  --z-above:     10;
  --z-nav:       100;
  --z-overlay:   200;
  --z-modal:     300;
}

/* -----------------------------------------------------------------------
   3. CSS RESET & BASE
   ----------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Remove list styles on ul/ol with role="list" */
ul[role='list'],
ol[role='list'] {
  list-style: none;
}

img, video {
  max-width: 100%;
  height: auto;
  display: block;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* Focus styles — accessible */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* -----------------------------------------------------------------------
   4. TYPOGRAPHY SYSTEM
   ----------------------------------------------------------------------- */

/* Headings — editorial hierarchy */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
}

/* Serif headlines — used for article/editorial titles */
.headline-serif {
  font-family: var(--font-serif);
}

h1 { font-size: clamp(1.875rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.5rem); }
h4 { font-size: clamp(1.1rem, 2vw, 1.25rem); }
h5 { font-size: var(--text-base); font-weight: 600; }
h6 { font-size: var(--text-sm);   font-weight: 600; }

p {
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

p + p {
  margin-top: var(--space-4);
}

strong { font-weight: 600; color: var(--color-text-primary); }
em     { font-style: italic; }

/* Category label style */
.label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
}

/* Meta text — author, date, reading time */
.meta {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* -----------------------------------------------------------------------
   5. LAYOUT UTILITIES
   ----------------------------------------------------------------------- */

.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--wide {
  max-width: var(--container-wide);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--article {
  max-width: var(--article-max);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

/* Section spacing */
.section {
  padding-block: var(--space-12);
}

.section--sm {
  padding-block: var(--space-8);
}

.section--lg {
  padding-block: var(--space-20);
}

/* Dividers */
.divider {
  border: none;
  border-top: var(--border-thin);
  margin-block: var(--space-8);
}

.divider--light {
  border-top: var(--border-light);
}

/* -----------------------------------------------------------------------
   6. GRID SYSTEMS
   ----------------------------------------------------------------------- */

/* Article + Sidebar layout */
.layout-article-sidebar {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: var(--space-10);
  align-items: start;
}

/* 3-column editorial grid */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

/* 4-column grid */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
}

/* 2-column grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}

/* Featured story layout: 1 large + 2 secondary */
.grid-featured {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
}

/* Homepage primary layout: hero-wide */
.grid-featured-3 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0;
}

/* -----------------------------------------------------------------------
   7. ADVERTISEMENT SLOTS
   ----------------------------------------------------------------------- */

.ad-slot {
  background: var(--color-ad-bg);
  border: var(--border-thin);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.ad-slot__label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: var(--space-2);
}

.ad-slot__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  text-align: center;
  gap: var(--space-2);
}

.ad-slot__placeholder span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Standard IAB ad sizes — reserved to prevent CLS */
.ad-slot--leaderboard {
  width: 100%;
  min-height: 90px;
}

.ad-slot--rectangle {
  width: 300px;
  min-height: 250px;
}

.ad-slot--rectangle-full {
  width: 100%;
  min-height: 250px;
}

.ad-slot--halfpage {
  width: 300px;
  min-height: 600px;
}

.ad-slot--banner-wide {
  width: 100%;
  min-height: 100px;
}

/* -----------------------------------------------------------------------
   8. SPONSORED CONTENT LABELS
   ----------------------------------------------------------------------- */

.sponsored-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a7222;
  background: var(--color-sponsored);
  border: 1px solid var(--color-sponsored-border);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* -----------------------------------------------------------------------
   9. READING PROGRESS BAR
   ----------------------------------------------------------------------- */

.reading-progress {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--color-accent);
  z-index: var(--z-nav);
  transition: width 100ms linear;
}

/* -----------------------------------------------------------------------
   10. SKIP LINK (Accessibility)
   ----------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-accent);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  z-index: var(--z-modal);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
}

/* -----------------------------------------------------------------------
   11. UTILITY CLASSES
   ----------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

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

.font-serif  { font-family: var(--font-serif); }
.font-sans   { font-family: var(--font-sans); }

.fw-normal  { font-weight: 400; }
.fw-medium  { font-weight: 500; }
.fw-semibold{ font-weight: 600; }
.fw-bold    { font-weight: 700; }

.mt-auto { margin-top: auto; }
.mb-0    { margin-bottom: 0; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.hidden { display: none; }
.block  { display: block; }

/* -----------------------------------------------------------------------
   12. RESPONSIVE BREAKPOINTS
   ----------------------------------------------------------------------- */

/* Tablet and below */
@media (max-width: 1024px) {
  .layout-article-sidebar {
    grid-template-columns: 1fr;
  }

  .grid-featured {
    grid-template-columns: 1fr;
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .sidebar {
    display: none; /* Sidebar collapses on tablet */
  }
}

/* Mobile */
@media (max-width: 768px) {
  :root {
    --space-6: 1.25rem;
  }

  .container,
  .container--wide,
  .container--article {
    padding-inline: var(--space-4);
  }

  .grid-3,
  .grid-4,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .grid-featured {
    grid-template-columns: 1fr;
  }

  .grid-featured-3 {
    grid-template-columns: 1fr;
  }

  .section {
    padding-block: var(--space-8);
  }

  .section--lg {
    padding-block: var(--space-12);
  }

  .ad-slot--rectangle,
  .ad-slot--halfpage {
    width: 100%;
  }

  /* Inline homepage split panels become a vertical, touch-friendly stack. */
  .grid-2 > div[style*="border-left"] {
    border-left: 0 !important;
    border-top: var(--border-thin);
    padding-left: 0 !important;
    padding-top: var(--space-8);
  }
}

@media (max-width: 480px) {
  .container,
  .container--wide,
  .container--article {
    padding-inline: var(--space-4);
  }
}
