/* ==========================================================================
   Red Rock Daily — Washington County, Utah local news & guides
   Professional news design system (Step 1 redesign)
   --------------------------------------------------------------------------
   Structure:
     1.  Design tokens          — color / type / space / shadow / radius
     2.  Dark mode tokens       — prefers-color-scheme + [data-theme]
     3.  Reset & base           — box-sizing, body, links, images, focus
     4.  Layout                 — .wrap container, section rhythm
     5.  Masthead               — topbar, brand, sticky primary nav
     6.  Breaking banner
     7.  Breadcrumbs
     8.  Hero section
     9.  Section headers
    10.  Article card grid
    11.  Newsletter
    12.  Article (.post)
    13.  Standalone pages (.page, .catlist)
    14.  Footer
    15.  Utilities & reduced motion
   Mobile-first: base rules target small screens; media queries add
   structure at 640 / 760 / 920 / 1120px.
   ========================================================================== */

/* ==========================================================================
   1. Design tokens (light theme defaults)
   ========================================================================== */
:root {
  /* Red-rock palette — Navajo sandstone, vermilion, warm sand & sun */
  --brand: #b4432a;            /* primary vermilion */
  --brand-deep: #93351f;       /* hover / pressed accents */
  --brand-soft: #f6e3da;       /* tinted wash for chips & badges */
  --accent: #d9982f;           /* warm sun accent */
  --bg: #faf6ef;               /* page background — warm sand */
  --surface: #ffffff;          /* cards, nav, sticky surfaces */
  --surface-alt: #f1eadf;      /* alternate washes, notes */
  --ink: #29211a;              /* headings — warm near-black */
  --text: #463a2e;             /* body copy — warm brown-gray */
  --muted: #857568;            /* secondary / meta text */
  --line: #e5dacb;             /* hairlines & borders */
  --line-strong: #cfc1ae;      /* emphasized borders */

  /* Footer is dark in both themes */
  --footer-bg: #221b16;
  --footer-text: #c9beb2;
  --footer-muted: #8d8175;
  --footer-line: #3a3128;
  --footer-link: #d8c9b8;

  /* Typography — serif headlines, sans body */
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(41, 33, 26, 0.06);
  --shadow-md: 0 6px 18px -6px rgba(41, 33, 26, 0.14);
  --shadow-lg: 0 16px 36px -12px rgba(41, 33, 26, 0.2);

  /* Layout */
  --container: 1180px;
  --focus-ring: 2px solid var(--brand);

  /* Back-compat aliases — referenced by inline styles on some pages */
  --gray: var(--muted);
  --serif: var(--font-serif);
  --light: var(--surface-alt);
}

/* ==========================================================================
   2. Dark mode tokens
   Applied automatically via prefers-color-scheme, or manually by adding
   class="dark" / data-theme="dark" to <html>.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #e0784f;
    --brand-deep: #c95c37;
    --brand-soft: #4a2a1e;
    --accent: #e0a83f;
    --bg: #16120e;
    --surface: #201a15;
    --surface-alt: #2a221b;
    --ink: #f2e9dc;
    --text: #d6c8b8;
    --muted: #998b7c;
    --line: #3a2f26;
    --line-strong: #4d4034;
    --footer-bg: #0f0c09;
    --footer-text: #c9beb2;
    --footer-muted: #8d8175;
    --footer-line: #332b24;
    --footer-link: #e0d2c2;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 18px -6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 36px -12px rgba(0, 0, 0, 0.55);
  }
}

:root.dark,
:root[data-theme="dark"] {
  --brand: #e0784f;
  --brand-deep: #c95c37;
  --brand-soft: #4a2a1e;
  --accent: #e0a83f;
  --bg: #16120e;
  --surface: #201a15;
  --surface-alt: #2a221b;
  --ink: #f2e9dc;
  --text: #d6c8b8;
  --muted: #998b7c;
  --line: #3a2f26;
  --line-strong: #4d4034;
  --footer-bg: #0f0c09;
  --footer-text: #c9beb2;
  --footer-muted: #8d8175;
  --footer-line: #332b24;
  --footer-link: #e0d2c2;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px -6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 36px -12px rgba(0, 0, 0, 0.55);
}

/* ==========================================================================
   3. Reset & base
   ========================================================================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--brand);
  color: #fff;
}

a {
  color: var(--brand-deep);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   4. Layout
   ========================================================================== */
.wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 640px) {
  .wrap { padding: 0 var(--space-5); }
}

main {
  display: block; /* normalize <main> in older browsers */
}

/* ==========================================================================
   5. Masthead — topbar, brand, sticky nav
   The header is laid out as a plain pass-through (display: contents) so the
   primary nav can stick to the viewport for the full page height. Browsers
   without support fall back to a sticky full masthead.
   ========================================================================== */
.site-header {
  display: contents;
}

@supports not (display: contents) {
  .site-header {
    display: block;
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
}

.topbar {
  background: var(--ink);
  color: var(--bg);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: var(--space-2) 0;
}

.topbar .wrap {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.brand {
  padding: 1.5rem 0 1.125rem;
  text-align: center;
}

.brand h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 6vw, 2.9rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0.005em;
}

.brand h1 a {
  color: var(--ink);
}

.brand h1 a:hover {
  color: var(--brand);
  text-decoration: none;
}

.brand h1 .red {
  color: var(--brand);
}

.tagline {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-top: 0.375rem;
}

/* Primary navigation — sticky */
.mainnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.mainnav .wrap {
  display: flex;
}

.mainnav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  width: 100%;
  /* Mobile: one scrollable row instead of wrapping */
  overflow-x: auto;
  flex-wrap: nowrap;
  justify-content: flex-start;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.mainnav ul::-webkit-scrollbar {
  display: none;
}

.mainnav a {
  display: block;
  padding: 0.8rem 0.875rem;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--ink);
  border-radius: var(--radius-sm);
}

.mainnav a:hover {
  background: var(--surface-alt);
  color: var(--brand);
  text-decoration: none;
}

@media (min-width: 760px) {
  .mainnav ul {
    overflow: visible;
    flex-wrap: wrap;
  }
}

/* ==========================================================================
   6. Breaking banner
   ========================================================================== */
.breaking {
  background: var(--brand);
  color: #fff;
  font-size: 0.85rem;
  padding: var(--space-2) 0;
}

.breaking b {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: 0.5rem;
}

.breaking a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.breaking a:hover {
  color: #fff;
}

/* ==========================================================================
   7. Breadcrumbs
   Ready-to-use component (wrap in <nav class="breadcrumbs" aria-label="Breadcrumb">).
   ========================================================================== */
.breadcrumbs {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 1rem 0 0;
}

.breadcrumbs ol,
.breadcrumbs ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}

.breadcrumbs li {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.breadcrumbs li + li::before {
  content: "/";
  color: var(--line-strong);
}

.breadcrumbs a {
  color: var(--muted);
}

.breadcrumbs a:hover {
  color: var(--brand);
  text-decoration: underline;
}

.breadcrumbs [aria-current="page"],
.breadcrumbs .current {
  color: var(--ink);
  font-weight: 600;
}

/* ==========================================================================
   8. Hero section — feature story + latest list
   ========================================================================== */
.hero {
  display: grid;
  gap: var(--space-6);
  padding: clamp(1.25rem, 3vw, 2.5rem) 0;
}

.hero-main img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-4);
}

.hero-main h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.18;
  font-weight: 700;
  margin-bottom: var(--space-3);
}

.hero-main h2 a {
  color: var(--ink);
}

.hero-main h2 a:hover {
  color: var(--brand);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.hero-main p {
  color: var(--text);
  font-size: 0.95rem;
  max-width: 44rem;
}

.hero-side {
  border-top: 2px solid var(--brand);
  padding-top: var(--space-4);
}

.hero-side h3 {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: var(--space-2);
}

.hero-side ul {
  list-style: none;
  counter-reset: hero-side;
}

.hero-side li {
  counter-increment: hero-side;
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.hero-side li:last-child {
  border-bottom: 0;
}

.hero-side li::before {
  content: counter(hero-side, decimal-leading-zero);
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand);
  flex: none;
}

.hero-side li a {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.4;
  color: var(--ink);
}

.hero-side li a:hover {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (min-width: 920px) {
  .hero {
    grid-template-columns: 2fr 1fr;
    align-items: start;
  }
}

/* ==========================================================================
   9. Section headers
   ========================================================================== */
.section {
  padding: clamp(1.25rem, 3vw, 2rem) 0;
  border-top: 1px solid var(--line);
}

.section h2 {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--space-5);
}

/* Red accent tick beside section headings */
.section h2::before {
  content: "";
  width: 5px;
  height: 1.1em;
  background: var(--brand);
  border-radius: 2px;
  flex: none;
}

/* ==========================================================================
   10. Article card grid
   ========================================================================== */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.25rem 1.375rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

/* Brand accent bar that sweeps in on hover */
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1rem;
  right: 1rem;
  height: 3px;
  background: var(--brand);
  border-radius: 0 0 3px 3px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s ease;
}

.card h3 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  line-height: 1.35;
  font-weight: 700;
}

.card h3 a {
  color: var(--ink);
}

.card h3 a:hover {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.card .meta {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 0.625rem;
}

.card p {
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.65;
  margin-top: 0.5rem;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.card:hover::before {
  transform: scaleX(1);
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-5);
  }
}

/* ==========================================================================
   11. Newsletter
   ========================================================================== */
.newsletter {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1.25rem, 3vw, 2rem);
  margin: var(--space-6) 0;
  text-align: center;
}

.newsletter h3 {
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 3vw, 1.6rem);
  color: var(--ink);
  margin-bottom: 0.375rem;
}

.newsletter p {
  color: var(--text);
  font-size: 0.9rem;
  max-width: 34rem;
  margin: 0 auto 1.25rem;
}

.newsletter form {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.newsletter input[type="email"] {
  padding: 0.75rem 1rem;
  width: min(100%, 20rem);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.newsletter input[type="email"]::placeholder {
  color: var(--muted);
}

.newsletter button {
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.newsletter button:hover {
  background: var(--brand-deep);
}

/* ==========================================================================
   12. Article (.post)
   ========================================================================== */
.post {
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) 0 3.5rem;
}

.post h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  line-height: 1.16;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--space-4);
}

.post .meta {
  color: var(--muted);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.875rem;
  margin-bottom: 1.25rem;
}

.byline {
  color: var(--muted);
  font-weight: 600;
}

.post h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 3vw, 1.7rem);
  color: var(--ink);
  margin: 2.25rem 0 0.625rem;
}

.post h3 {
  font-family: var(--font-serif);
  font-size: clamp(1.15rem, 2.5vw, 1.35rem);
  color: var(--ink);
  margin: 1.75rem 0 0.5rem;
}

.post p {
  font-size: 1.05rem;
  line-height: 1.75;
  margin-bottom: 0.875rem;
}

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

.post li {
  margin-bottom: 0.375rem;
}

.post li strong {
  color: var(--ink);
}

.post img {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.post .sources {
  margin-top: 2.25rem;
  padding: 1rem 1.25rem;
  background: var(--surface-alt);
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem;
  color: var(--text);
}

.post .sources h3 {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 0.375rem;
}

/* ==========================================================================
   13. Standalone pages
   ========================================================================== */
.page {
  max-width: 48rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) 0 3.5rem;
}

.page h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4.5vw, 2.4rem);
  color: var(--ink);
  margin-bottom: var(--space-4);
}

.page h2 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  color: var(--ink);
  margin: 1.75rem 0 0.5rem;
}

.page p {
  margin-bottom: 0.875rem;
}

.page ul {
  margin: 0 0 1.25rem 1.5rem;
}

.catlist {
  max-width: 52rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) 0;
}

.catlist h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4.5vw, 2.4rem);
  color: var(--ink);
  margin-bottom: var(--space-5);
  padding-bottom: 0.625rem;
  border-bottom: 2px solid var(--brand);
  display: inline-block;
}

/* Cards inside a category listing read as a headline index */
.catlist .card {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 1rem 0;
  box-shadow: none;
  overflow: visible;
}

.catlist .card::before {
  display: none;
}

.catlist .card h3 {
  font-size: clamp(1.15rem, 3vw, 1.35rem);
}

.catlist .card:hover {
  transform: none;
  border-color: var(--line);
}

.catlist .card:hover h3 a {
  color: var(--brand);
}

/* ==========================================================================
   14. Footer
   ========================================================================== */
.site-footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  font-size: 0.875rem;
  margin-top: var(--space-8);
  padding: var(--space-8) 0 var(--space-5);
}

.site-footer .cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

.site-footer h4 {
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-3);
}

.site-footer ul {
  list-style: none;
}

.site-footer li {
  margin-bottom: 0.375rem;
}

.site-footer a {
  color: var(--footer-link);
}

.site-footer a:hover {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer p {
  color: var(--footer-text);
}

.copyright {
  border-top: 1px solid var(--footer-line);
  margin-top: var(--space-6);
  padding-top: 1.25rem;
  text-align: center;
  color: var(--footer-muted);
  font-size: 0.8rem;
}

@media (min-width: 700px) {
  .site-footer .cols {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

/* ==========================================================================
   15. Utilities & reduced motion
   ========================================================================== */
/* Skip link — first tab stop; visually hidden until focused */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1.3;
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 0;
  top: 0;
  outline: 0;
  box-shadow: var(--shadow-md);
}

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
