/* ENSURE THEME ATTRIBUTE IS READ */
html, body {
  color-scheme: light dark;
}

/* --------------------------------------------------
   GLOBAL RESET + BASE
-------------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  padding: 1.5rem 1rem;
  transition: background 0.25s ease, color 0.25s ease;
}

/* --------------------------------------------------
   PREMIUM ENGINEERING THEME VARIABLES
-------------------------------------------------- */
:root {
  /* Dark mode base */
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --bg-hover: #1d242d;

  --text: #f3f4f6;
  --text-muted: #9ca3af;

  --border: #2a2f36;
  --border-soft: #1f242c;

  /* Muted Slate‑Teal Accent (T1) */
  --accent: #3aa6a0;
  --accent-soft: #2f8f89;
  --accent-hover: #4fc0b9;

  --radius: 8px;
  --max-width: 860px;

  --card-bg: #161b22;
  --hover-bg: #1d242d;

  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.35);

  /* Subtle premium gradients */
  --gradient-main:
    radial-gradient(circle at top left, rgba(58, 166, 160, 0.12), transparent 55%),
    radial-gradient(circle at top right, rgba(58, 166, 160, 0.10), transparent 55%);

  --gradient-card:
    linear-gradient(135deg, rgba(58, 166, 160, 0.18), rgba(58, 166, 160, 0.10));
}

/* LIGHT MODE */
[data-theme="light"] {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-hover: #f0f4f5;

  --text: #1f2937;
  --text-muted: #6b7280;

  --border: #e5e7eb;
  --border-soft: #eceff1;

  --card-bg: #ffffff;
  --hover-bg: #f4f7f8;

  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.08);

  --gradient-main:
    radial-gradient(circle at top left, rgba(58, 166, 160, 0.10), transparent 55%),
    radial-gradient(circle at top right, rgba(58, 166, 160, 0.08), transparent 55%);

  --gradient-card:
    linear-gradient(135deg, rgba(58, 166, 160, 0.15), rgba(58, 166, 160, 0.08));
}

/* --------------------------------------------------
   PAGE WRAPPER
-------------------------------------------------- */
.page-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* --------------------------------------------------
   GLOBAL NAVIGATION
-------------------------------------------------- */
.global-nav {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto 2rem auto;
  padding: 0.75rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.92rem;
}

.global-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.global-nav a:hover {
  color: var(--text);
  border-color: var(--accent-soft);
  background: rgba(58, 166, 160, 0.12);
  box-shadow: 0 0 0 1px rgba(58, 166, 160, 0.25);
}

.theme-toggle {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent-soft);
}

/* --------------------------------------------------
   SITE HEADER / FOOTER
-------------------------------------------------- */
.site-header {
  max-width: var(--max-width);
  margin: 0 auto 1.5rem auto;
  padding-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-soft);
}

.site-header .logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.site-header .nav a {
  margin-left: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.site-header .nav a:hover {
  color: var(--text);
  border-color: var(--accent-soft);
  background: rgba(58, 166, 160, 0.12);
}

.site-footer {
  max-width: var(--max-width);
  margin: 3rem auto 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

/* --------------------------------------------------
   HOMEPAGE HERO
-------------------------------------------------- */
.home-hero {
  text-align: center;
  margin: 2.5rem auto 2.75rem auto;
  max-width: var(--max-width);
  position: relative;
  padding: 2.25rem 1.25rem 2.5rem;
  border-radius: 1.5rem;
  background: var(--gradient-main), linear-gradient(145deg, var(--bg), var(--bg-elevated));
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-soft);
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 750;
  margin-bottom: 0.75rem;
  letter-spacing: 0.02em;
}

.hero-tagline {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 520px;
  margin: 0 auto;
}

/* --------------------------------------------------
   SEARCH BAR + TYPING OVERLAY
-------------------------------------------------- */
.search-container {
  margin: 1.9rem auto 1.1rem auto;
  max-width: 600px;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--accent-soft);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  box-shadow: 0 0 0 1px rgba(58, 166, 160, 0.15);
  position: relative;
  z-index: 2;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 0 22px rgba(58, 166, 160, 0.25),
    0 0 45px rgba(58, 166, 160, 0.15);
}

/* Typing overlay */
.typing-overlay {
  position: absolute;
  top: 50%;
  left: 1.1rem;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  font-size: 0.98rem;
  z-index: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cursor {
  display: inline-block;
  margin-left: 2px;
  color: var(--accent);
  animation: blink 1s step-start infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* --------------------------------------------------
   RANDOM BUTTON
-------------------------------------------------- */
.random-wrapper {
  margin-top: 1.1rem;
  display: flex;
  justify-content: center;
}

.random-btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  background-image: var(--gradient-card);
  color: var(--text);
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid var(--accent-soft);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.random-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

/* --------------------------------------------------
   TRUST SECTION
-------------------------------------------------- */
.trust-section {
  max-width: var(--max-width);
  margin: 2.75rem auto 2.5rem auto;
  padding: 1.75rem 1.5rem;
  border-radius: 1.25rem;
  background: linear-gradient(145deg, var(--bg), var(--bg-elevated));
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
}

.trust-section h2 {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
}

.trust-section p {
  color: var(--text-muted);
  font-size: 0.98rem;
  margin-bottom: 1.1rem;
}

.trust-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
}

.trust-links a {
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--accent-soft);
  background: var(--bg-elevated);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.trust-links a:hover {
  background: rgba(58, 166, 160, 0.12);
  border-color: var(--accent-hover);
  color: var(--text);
}

/* --------------------------------------------------
   FEATURED CATEGORIES
-------------------------------------------------- */
.featured-categories {
  max-width: var(--max-width);
  margin: 0 auto 2.5rem auto;
}

.featured-categories h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
}

.category-card {
  flex: 1 1 160px;
  min-width: 0;
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  background: var(--gradient-card), var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 0.95rem;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.category-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent-hover);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

/* --------------------------------------------------
   LATEST GRID
-------------------------------------------------- */
.latest-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  margin-top: 2.5rem;
}

.latest-grid h2 {
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.article-card {
  padding: 1.25rem;
  border-radius: 1rem;
  background: var(--gradient-card), var(--bg-elevated);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease,
    box-shadow 0.2s ease;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.article-card:hover {
  background: var(--gradient-main), var(--bg-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.article-card h3 {
  margin-bottom: 0.4rem;
  font-size: 1.1rem;
}

.updated {
  opacity: 0.7;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --------------------------------------------------
   ARTICLE PAGE
-------------------------------------------------- */
.article-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
}

.article {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 2.1rem 1.75rem;
  margin-top: 1.25rem;
  box-shadow: var(--shadow-soft);
}

.article h1 {
  font-size: 2.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  text-align: left;
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
}

.breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--accent);
}

/* Sections inside article */
.highlights {
  margin-top: 1.5rem;
}

.highlights h2 {
  margin-bottom: 0.75rem;
}

.human,
.technical,
.affiliate {
  margin-top: 2rem;
}

/* --------------------------------------------------
   TYPOGRAPHY
-------------------------------------------------- */
h1, h2, h3 {
  font-weight: 600;
}

h2 {
  font-size: 1.45rem;
  margin-top: 2.25rem;
  margin-bottom: 1rem;
}

p {
  margin-bottom: 1.25rem;
  font-size: 1.02rem;
}

.article p,
.article li {
  max-width: 700px;
}

/* --------------------------------------------------
   LINKS
-------------------------------------------------- */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
}

/* --------------------------------------------------
   LISTS
-------------------------------------------------- */
ul {
  margin: 1rem 0 1.5rem 1.25rem;
}

li {
  margin-bottom: 0.6rem;
}

/* --------------------------------------------------
   RELATED + EXPLORE MORE
-------------------------------------------------- */
.related,
.explore-more {
  margin-top: 2.5rem;
}

.related h2,
.explore-more h2 {
  margin-bottom: 0.75rem;
}

.related ul,
.explore-more ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.related li,
.explore-more li {
  margin-bottom: 0.5rem;
}

/* --------------------------------------------------
   HOMEPAGE INTERNAL LINKS (BOTTOM)
-------------------------------------------------- */
.homepage-internal-links {
  max-width: var(--max-width);
  margin: 2.75rem auto 0 auto;
}

.homepage-internal-links h2 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.link-btn {
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--bg), var(--bg-elevated));
  border: 1px solid var(--accent-soft);
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease,
    box-shadow 0.2s ease;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
}

.link-btn:hover {
  background: linear-gradient(145deg, var(--bg-hover), var(--bg-elevated));
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
}

/* --------------------------------------------------
   IMAGES
-------------------------------------------------- */
img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* --------------------------------------------------
   CLUSTER / CATEGORY / TOPIC WRAPPERS
-------------------------------------------------- */
.cluster-wrapper,
.category-wrapper,
.topic-wrapper {
  max-width: var(--max-width);
  margin: 1.5rem auto 0 auto;
  background: var(--bg-elevated);
  border-radius: 1.25rem;
  border: 1px solid var(--border);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow-soft);
}

.cluster-content,
.category-content,
.topic-content {
  font-size: 1.02rem;
}

/* --------------------------------------------------
   CLUSTER PAGE (LEGACY CLASS)
-------------------------------------------------- */
.cluster-page {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-top: 1rem;
}

.cluster-header {
  margin-bottom: 1.5rem;
}

.cluster-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.cluster-header p {
  color: var(--text-muted);
  font-size: 0.98rem;
}

.cluster-nav {
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.cluster-nav a {
  color: var(--text-muted);
}

.cluster-nav a:hover {
  color: var(--accent);
}

.cluster-list {
  list-style: none;
  margin: 1rem 0 0 0;
  padding: 0;
}

.cluster-article {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.cluster-article:last-child {
  border-bottom: none;
}

.cluster-article-title {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.cluster-article-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.cluster-summary {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0.35rem 0 0.25rem;
}

.cluster-updated {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --------------------------------------------------
   GLOBAL FOOTER (FIXED)
-------------------------------------------------- */
.global-footer {
  width: 100%;
  max-width: var(--max-width);
  margin: 3rem auto 0 auto;
  padding-top: 2rem;
  border-top: 1px solid var(--border-soft);

  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;

  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--accent-hover);
}

.footer-bottom {
  width: 100%;
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
