/* =========================================================
   TechNews SG — Responsive Tech/Digital News Template
   Plain HTML/CSS/JS · Mobile-first · Light/Dark theme
   Designed for Adcash ad monetization (SG market)
   ========================================================= */

/* ---------- Design tokens ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;

  /* Light theme */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6ea;
  --text: #15181d;
  --text-muted: #5b6573;
  --text-faint: #8a94a3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 30px rgba(16, 24, 40, 0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1200px;
  --header-h: 62px;

  /* Category gradients (pure CSS thumbnails, no external images) */
  --cat-ai: linear-gradient(135deg, #6366f1, #a855f7);
  --cat-tech: linear-gradient(135deg, #0ea5e9, #2563eb);
  --cat-gadget: linear-gradient(135deg, #f59e0b, #ef4444);
  --cat-apps: linear-gradient(135deg, #10b981, #14b8a6);
  --cat-startup: linear-gradient(135deg, #ec4899, #f43f5e);
  --cat-security: linear-gradient(135deg, #475569, #1e293b);
  --cat-gaming: linear-gradient(135deg, #8b5cf6, #d946ef);
  --cat-crypto: linear-gradient(135deg, #f59e0b, #fbbf24);
  --cat-cloud: linear-gradient(135deg, #0ea5e9, #22d3ee);
  --cat-tech: linear-gradient(135deg, #0ea5e9, #2563eb);
}

[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1c232c;
  --border: #2a323d;
  --text: #e6e9ee;
  --text-muted: #9aa6b2;
  --text-faint: #6b7682;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: #1e2233;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.55);
}

/* ---------- Thumbnail / hero image: <img> based (reliable everywhere) ---------- */
.thumb {
  position: relative;
  overflow: hidden;
}
.thumb img,
.hero-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background-color: var(--surface-3);
}

/* Ads disabled (pre-launch): hide all ad zones entirely */
.no-ads .ad-zone,
.no-ads .mobile-sticky-ad { display: none !important; }

/* ---------- Reset / base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.25s ease, color 0.25s ease;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

.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;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--header-h);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.brand .logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 900;
}
.brand .sg {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  letter-spacing: 0.04em;
}

.main-nav {
  display: none;
  gap: 4px;
  margin-left: 10px;
}
.main-nav a {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.18s, color 0.18s;
}
.main-nav a:hover,
.main-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 19px; height: 19px; }
/* Show the icon that switches AWAY from the current theme */
.icon-sun { display: none; }
.icon-moon { display: inline; }
[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }

/* Search */
.search-box {
  display: none;
  position: relative;
}
.search-box input {
  width: 200px;
  height: 38px;
  padding: 0 14px 0 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.18s, width 0.2s;
}
.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  width: 230px;
}
.search-box .s-icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  width: 16px; height: 16px;
}

/* Mobile nav toggle */
.nav-toggle { display: grid; }

/* ---------- Mobile menu ---------- */
.mobile-menu {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 16px 14px;
}
.mobile-menu.open { display: block; }
.mobile-menu a {
  display: block;
  padding: 11px 8px;
  border-radius: 8px;
  font-weight: 500;
  color: var(--text-muted);
}
.mobile-menu a:hover { background: var(--surface-2); color: var(--accent); }

/* ---------- Layout grid ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  padding: 28px 0 48px;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}
.section-title::before {
  content: "";
  width: 4px; height: 22px;
  border-radius: 4px;
  background: var(--accent);
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  gap: 18px;
  margin-bottom: 14px;
}
.hero-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px;
  color: #fff;
  isolation: isolate;
}
.hero-card .thumb {
  position: absolute;
  inset: 0;
  z-index: -1;
}
.hero-card .thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.25) 55%, rgba(0,0,0,0) 100%);
}
.hero-card .tag { align-self: flex-start; }
.hero-card h1 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  line-height: 1.15;
  margin: 10px 0 8px;
  letter-spacing: -0.02em;
}
.hero-card p { margin: 0; color: rgba(255,255,255,0.85); max-width: 60ch; }
.hero-card .meta { color: rgba(255,255,255,0.7); margin-top: 12px; }

/* ---------- Cards grid ---------- */
.news-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.card .thumb {
  aspect-ratio: 16 / 9;
  position: relative;
}
.card .thumb .play {
  position: absolute;
  right: 10px; bottom: 10px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  color: #111;
  display: grid; place-items: center;
  font-size: 0.75rem;
}
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 {
  font-size: 1.02rem;
  line-height: 1.35;
  margin: 0;
  letter-spacing: -0.01em;
}
.card h3 a:hover { color: var(--accent); }
.card .excerpt {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .meta {
  margin-top: auto;
  font-size: 0.78rem;
  color: var(--text-faint);
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Category tag */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.tag.alt { background: rgba(255,255,255,0.18); color: #fff; backdrop-filter: blur(4px); }

.meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }

/* ---------- Sidebar ---------- */
.sidebar { display: grid; gap: 22px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel h4 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.trending li { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border); }
.trending li:last-child { border-bottom: 0; }
.trending .rank {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.8rem;
  display: grid; place-items: center;
}
.trending a { font-size: 0.88rem; font-weight: 600; line-height: 1.35; }
.trending a:hover { color: var(--accent); }
.trending .t-meta { font-size: 0.72rem; color: var(--text-faint); margin-top: 2px; }

.newsletter input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  margin-bottom: 9px;
  font-size: 0.9rem;
}
.newsletter input:focus { outline: none; border-color: var(--accent); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  transition: background 0.18s, transform 0.1s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.98); }

/* ---------- Adcash ad zones ---------- */
.ad-zone {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed color-mix(in srgb, var(--text-faint) 45%, transparent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-faint);
  overflow: hidden;
  transition: border-color 0.2s;
}
.ad-zone.loaded { border-style: solid; border-color: var(--border); background: var(--surface); }
.ad-zone .ad-label {
  position: absolute;
  top: 6px; left: 8px;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.75;
  z-index: 2;
}
.ad-zone .ad-placeholder {
  text-align: center;
  font-size: 0.78rem;
  padding: 6px;
  z-index: 1;
}
.ad-zone .ad-placeholder strong { display: block; font-size: 0.92rem; color: var(--text-muted); }
.ad-zone.size-leaderboard { min-height: 90px; }
.ad-zone.size-rectangle { min-height: 250px; }
.ad-zone.size-incontent { min-height: 120px; }
.ad-zone.size-footer { min-height: 100px; }
.ad-zone.size-sticky { min-height: 50px; }

/* Sticky mobile banner */
.mobile-sticky-ad {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  padding: 6px 8px
    calc(6px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  display: none;
}
.mobile-sticky-ad .close {
  position: absolute;
  top: -14px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  display: grid; place-items: center;
  z-index: 3;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 36px 0 28px;
  margin-top: 20px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 26px;
}
.footer-grid h5 { font-size: 0.9rem; font-weight: 800; margin: 0 0 12px; }
.footer-grid a { display: block; color: var(--text-muted); font-size: 0.88rem; padding: 4px 0; }
.footer-grid a:hover { color: var(--accent); }
.footer-bottom {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
}
.footer-bottom .links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-bottom a:hover { color: var(--accent); }

/* ---------- Article page ---------- */
.article {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 0 48px;
}
.breadcrumb { font-size: 0.82rem; color: var(--text-faint); margin-bottom: 14px; }
.breadcrumb a:hover { color: var(--accent); }
.article h1 {
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 6px 0 14px;
}
.article .meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.article .author { display: flex; align-items: center; gap: 9px; }
.article .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem;
}
.article .lead {
  font-size: 1.12rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.article .hero-img {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  margin: 22px 0;
  border: 1px solid var(--border);
}
.article h2 { font-size: 1.45rem; margin: 34px 0 12px; letter-spacing: -0.01em; }
.article h3 { font-size: 1.15rem; margin: 26px 0 10px; }
.article p { margin: 0 0 18px; }
.article ul.bullets { margin: 0 0 18px; padding-left: 4px; }
.article ul.bullets li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 9px;
}
.article ul.bullets li::before {
  content: "";
  position: absolute;
  left: 4px; top: 11px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.article blockquote {
  margin: 22px 0;
  padding: 14px 20px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text);
  font-style: italic;
}
.article .incontent-ad { margin: 26px 0; }
.share-row { display: flex; gap: 10px; margin: 30px 0; }
.share-row a {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: color 0.18s, border-color 0.18s;
}
.share-row a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Responsive breakpoints ---------- */
@media (min-width: 640px) {
  .news-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
  .mobile-sticky-ad { display: block; }
}

@media (min-width: 900px) {
  .main-nav { display: flex; }
  .nav-toggle { display: none; }
  .search-box { display: block; }
  .hero { grid-template-columns: 2fr 1fr; }
  .layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }
  .sidebar { position: sticky; top: calc(var(--header-h) + 20px); }
  .news-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .mobile-sticky-ad { display: none; }
}

@media (min-width: 1100px) {
  .news-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* ---------- Focus visibility (a11y) ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
