/* =========================
   Fourth Opinion - CSS Foundation
   ========================= */

/* ---- 1) Design tokens ---- */
:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Merriweather", ui-serif, Georgia, "Times New Roman", Times, serif;

  --maxw: 720px;
  --pad-x: 20px;

  --fz-base: 18px;
  --lh: 1.75;

  --fz-h1: 36px;
  --fz-h2: 24px;
  --fz-h3: 18px;

  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 22px;
  --space-5: 30px;
  --space-6: 44px;
  --space-7: 64px;

  /* Locked palette */
  --bg: #FAF9F7;
  --panel-bg: #F1EFEA;
  --text: #2C2F33;
  --muted: #4A4F55;
  --soft: #6B7076;

  --link: #2C2F33;
  --link-underline: rgba(44, 47, 51, 0.35);

  --line: rgba(44, 47, 51, 0.14);
  --panel-border: rgba(44, 47, 51, 0.12);

  --accent: #B08D57;

  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101010;
    --panel-bg: #191612;
    --text: #E7E1D7;
    --muted: #C5BEB2;
    --soft: #A79F94;

    --link: #EEE7DC;
    --link-underline: rgba(238, 231, 220, 0.35);

    --line: rgba(238, 231, 220, 0.18);
    --panel-border: rgba(238, 231, 220, 0.16);

    /* Keep accent brass, slightly lifted for dark backgrounds */
    --accent: #C9A76B;
  }

  /* Ensure images don’t get dimmed by browser heuristics */
  img { color-scheme: dark; }

  /* Slightly soften shadowing in dark mode */
  .highlight, .service-card, .card {
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  }

  /* Nav tuning for dark mode */
  .site-header {
    background: rgba(12, 12, 12, 0.94);
    border-bottom: 1px solid var(--line);
  }

  .site-nav a:hover {
    background: rgba(201, 167, 107, 0.16);
  }

  .site-nav a.is-active {
    background: rgba(201, 167, 107, 0.24);
    border-color: rgba(201, 167, 107, 0.4);
  }

  /* Panel/box backgrounds in dark mode */
  .hero-band,
  section.highlight,
  .service-card,
  .contact-box,
  .card {
    background: rgba(36, 32, 27, 0.92);
    border-color: var(--panel-border);
  }

  .hero-motif {
    opacity: 0.5;
    filter: brightness(1.15);
  }
}

/* Larger screens: slightly larger headings, maintain calm spacing */
@media (min-width: 900px) {
  :root {
    --fz-base: 19px;
    --fz-h1: 42px;
    --fz-h2: 26px;
    --fz-h3: 19px;
    --pad-x: 24px;
  }
}

/* ---- 2) Base resets ---- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { 
  height: auto;
  overflow-x: visible;
  overflow-y: visible;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fz-base);
  line-height: var(--lh);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Media defaults */
img, svg, video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---- 3) Layout spine ---- */
main#content {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--space-7) var(--pad-x);
}

/* Sections: spacing-led hierarchy */
section {
  padding-top: var(--space-6);
  border-top: 1px solid var(--line);
}

section:first-of-type {
  padding-top: 0;
  border-top: none;
}

/* ---- 4) Typography ---- */
h1, h2, h3 {
  margin: 0 0 var(--space-2);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1, h2 {
  font-family: var(--font-serif);
}

h3 {
  font-family: var(--font-sans);
}

h1 {
  font-family: var(--font-serif);
  font-size: var(--fz-h1);
  font-weight: 650;
}

h2 {
  font-size: var(--fz-h2);
  font-weight: 650;
  margin-top: 0;
}

h3 {
  font-size: var(--fz-h3);
  font-weight: 650;
}

p {
  margin: 0 0 var(--space-3);
  color: var(--muted);
}

p:last-child { margin-bottom: 0; }

/* Subtle emphasis */
strong { color: var(--text); }

/* ---- 5) Hero tuning ---- */
#hero h1 { color: var(--text); }

#hero .tagline {
  margin-top: var(--space-1);
  color: var(--text);
  font-weight: 600;
}

#hero .hero-lead {
  margin-top: var(--space-4);
  color: var(--text);
  font-weight: 600;
}

/* ---- 6) Services block ---- */
#services .service {
  padding: var(--space-3) 0;
}

#services .service + .service {
  border-top: 1px solid var(--line);
}

#services .service h3 {
  margin-bottom: var(--space-1);
  color: var(--text);
}

#services .service p {
  margin-bottom: 0;
  color: var(--muted);
}

/* ---- 7) Highlight panels (Independence + FAQ) ---- */
/* Add class="highlight" to those sections in HTML when ready */
section.highlight {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: var(--space-5) var(--space-4);
  margin-top: var(--space-6);
}

section.highlight + section {
  border-top: none; /* prevents double separators after panels */
}

/* ---- 8) Links ---- */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: var(--link);
}

/* ---- 9) Malay line ---- */
.malay {
  color: var(--soft);
  font-style: italic;
}

/* ---- 10) Accessibility helpers ---- */
:focus-visible {
  outline: 2px solid rgba(17, 17, 17, 0.5);
  outline-offset: 3px;
}

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

/* =========================
   Header / Nav
   ========================= */

.site-header {
  position: -webkit-sticky; /* Safari */
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;

  background: rgba(250, 249, 247, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

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

.header-inner {
  max-width: calc(var(--maxw) + 320px); /* wider than content to keep nav to two rows */
  margin: 0 auto;
  padding: 8px var(--pad-x); /* tighter */
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 3px 5px;
  border-radius: 999px; /* softer, more “editorial” */
  font-size: 0.84em;
}

.site-nav a:hover {
  color: var(--text);
  background: rgba(176, 141, 87, 0.10);
}

.site-nav a.cta {
  color: #ffffff;
  background: var(--accent);
  border: 1px solid rgba(0,0,0,0.08);
  font-size: 0.84em;
  padding: 5px 9px;
}

.site-nav a.cta:hover {
  filter: brightness(0.95);
}

/* Keep content from hiding under sticky header when using anchor links */
html {
  scroll-padding-top: 84px;
  scroll-behavior: smooth;
}

/* Tablet: prevent third wrap by switching to horizontal scroll */
@media (max-width: 1120px) and (min-width: 721px) {
  .site-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
    width: 100%;
    justify-content: flex-start;
    scrollbar-width: thin;
    scrollbar-color: rgba(176, 141, 87, 0.35) transparent;
  }

  .site-nav a {
    white-space: nowrap;
  }
}

/* Mobile: collapse nav into a horizontal scroll row (no JS) */
@media (max-width: 720px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .brand {
    align-self: center;
  }

  .site-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: var(--space-2);
    min-width: 0; /* allow horizontal scrolling when content overflows */
    padding-bottom: 6px;   /* space for scrollbar */
    margin-bottom: -6px;   /* avoid layout shift */
    scrollbar-width: thin;
    scrollbar-color: rgba(176, 141, 87, 0.35) transparent;
    width: 100%;
    justify-content: flex-start;
    scrollbar-gutter: stable;

  }

  .site-nav a {
    white-space: nowrap;
  }

  .site-nav::-webkit-scrollbar {
    height: 6px;
  }

  .site-nav::-webkit-scrollbar-thumb {
    background: rgba(176, 141, 87, 0.35);
    border-radius: 999px;
  }

  .site-nav::-webkit-scrollbar-track {
    background: transparent;
  }
}

/* =========================
   Footer
   ========================= */

.site-footer {
  margin-top: var(--space-7);
  padding: var(--space-5) var(--pad-x);
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.82em;
  color: var(--soft);
}

.footer-inner a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-inner a:hover {
  color: var(--text);
}

/* Mobile: stack footer content */
@media (max-width: 600px) {
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
}

/* =========================
   Hero band
   ========================= */

.hero-band {
  padding: var(--space-6) var(--space-4);
  background: rgba(241, 239, 234, 0.65);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}

.hero-band .tagline {
  color: var(--text);
  font-weight: 600;
  margin-top: var(--space-1);
}

.hero-band .hero-lead {
  margin-top: var(--space-4);
  color: var(--text);
  font-weight: 600;
}

.hero-band::after {
  content: "";
  display: block;
  margin-top: var(--space-4);
  width: 72px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.hero-actions {
  margin-top: var(--space-4);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* =========================
   Buttons (quiet, brass accent)
   ========================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 650;
  line-height: 1.2;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
}

.btn-primary:hover {
  filter: brightness(0.95);
}

/* =========================
   Highlight panels (Independence + FAQ)
   ========================= */

section.highlight {
  background: rgba(241, 239, 234, 0.65);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: var(--space-5) var(--space-4);
  margin-top: var(--space-6);
}

/* Keep section separators calm when panels are used */
section.highlight + section {
  border-top: none;
}

/* =========================
   Contact line
   ========================= */

.contact-line {
  margin-top: var(--space-3);
  color: var(--muted);
}

/* =========================
   Services: scannable structure
   ========================= */

.kicker {
  margin-top: var(--space-2);
  margin-bottom: var(--space-4);
  color: var(--muted);
  font-size: 0.98em;
}

.service-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

.service-card {
  background: rgba(241, 239, 234, 0.45);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.service-card h3 {
  margin-bottom: var(--space-1);
}

.service-card p {
  margin-bottom: 0;
}

/* 2-column only when there is enough width; keeps “paper” feel */
@media (min-width: 900px) {
  .service-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
  }
}

/* =========================
   Section rhythm tuning
   ========================= */

section {
  padding-top: var(--space-7);
  border-top: 1px solid var(--line);
}

section > h2 {
  margin-bottom: var(--space-3);
}

/* Slightly soften divider behavior after hero */
#hero + section {
  border-top: none;
}

/* Reduce “striped document” feeling */
section:not(.highlight) {
  scroll-margin-top: 96px;
}

/* =========================
   Active nav state
   ========================= */

.site-nav a.is-active {
  color: var(--text);
  background: rgba(176, 141, 87, 0.14);
  border: 1px solid rgba(176, 141, 87, 0.22);
}

.site-nav a.is-active.cta {
  color: #ffffff;
  background: var(--accent);
  border: 1px solid rgba(0,0,0,0.08);
}


/* =========================
   Contact polish
   ========================= */

.contact-panel {
  scroll-margin-top: 96px;
}

.contact-box {
  margin-top: var(--space-4);
  background: rgba(241, 239, 234, 0.55);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.contact-line {
  margin: 0 0 var(--space-2);
  color: var(--text);
  font-weight: 650;
}

.contact-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.98em;
}


/* =========================
   Article / Perspectives pages
========================= */
.page-article main#content {
  padding-top: calc(var(--space-7) + 32px);
}


.article { padding: 0 var(--pad-x) var(--space-8); }
.article-inner {
  max-width: var(--maxw);
  margin: 0 auto;
}

.kicker {
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--space-2);
}

.article-title {
  font-family: var(--font-serif);
  font-size: var(--fz-h1);
  line-height: 1.18;
  margin: 0 0 var(--space-5);
}

.article h2 {
  font-family: var(--font-serif);
  font-size: var(--fz-h2);
  margin: var(--space-7) 0 var(--space-3);
}

.article h3 {
  font-size: var(--fz-h3);
  margin: var(--space-5) 0 var(--space-2);
}

.lead {
  font-size: 19px;
  color: var(--text);
}

.linklist {
  list-style: none;
  padding: 0;
  margin: var(--space-3) 0 var(--space-7);
}

.linklist li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.linklist li:last-child { border-bottom: none; }

.article-footer {
  margin-top: var(--space-7);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.backlink {
  text-decoration: none;
  border-bottom: 1px solid var(--link-underline);
}

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


/* Reading Room lists */
.link-list{
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
}
.link-list li{
  margin: 0.35rem 0;
}
.link-list a{
  text-decoration: none;
}
.link-list a:hover{
  text-decoration: underline;
}


/* Brand logo image in nav */
.brand-logo{height:72px;max-width:320px;width:auto;display:block;}
@media (max-width:720px){.brand-logo{height:52px;max-width:240px;}}

/* Dark-mode overrides (placed at end to win cascade) */
@media (prefers-color-scheme: dark) {
  .site-header {
    background: rgba(12, 12, 12, 0.94);
    border-bottom: 1px solid var(--line);
  }

  .site-nav a:hover {
    background: rgba(201, 167, 107, 0.16);
  }

  .site-nav a.is-active {
    background: rgba(201, 167, 107, 0.24);
    border-color: rgba(201, 167, 107, 0.4);
  }

  .hero-band,
  section.highlight,
  .service-card,
  .contact-box,
  .card {
    background: rgba(36, 32, 27, 0.92);
    border-color: var(--panel-border);
  }

  .hero-motif {
    opacity: 0.5;
    filter: brightness(1.15);
  }
}
