/* ======================================================
   THEME VARIABLES
   Centralized color + spacing tokens.
   Treat this section as the design system.
====================================================== */
:root{
  /* Brand / structural */
  --navy-900:#0b2538;
  --navy-800:#0f2f4a;
  --navy-700:#123b5a;

  /* Typography */
  --ink:#0b1b2b;        /* Primary text */
  --muted:#526273;      /* Secondary / metadata */

  /* Surfaces */
  --bg:#ffffff;
  --bg-muted:#f4f7fb;
  --card:#ffffff;

  /* Borders & elevation */
  --border:#d7e1ea;
  --shadow:0 10px 28px rgba(0,0,0,0.08);

  /* Accents */
  --accent:#0f4b78;
}

/* ======================================================
   RESET / BASE
====================================================== */
*{ box-sizing:border-box; }

html{ scroll-behavior:smooth; }

body{
  margin:0;
  font-family:
    ui-sans-serif, system-ui, -apple-system,
    Segoe UI, Roboto, Helvetica, Arial,
    "Noto Sans Thai","Sarabun","Thonburi","Tahoma",sans-serif;

  color:var(--ink);
  background:var(--bg);
  line-height:1.55;
}

/* Page width constraint */
.container{
  width:min(1120px, calc(100% - 2rem));
  margin:0 auto;
}

/* ======================================================
   TOP BAR (Global header)
====================================================== */
.topbar{
  background:var(--navy-900);
  color:#fff;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap; /* KEY FIX */
}

.topbar-title{
  font-size:0.85rem;
  font-weight:800;
  letter-spacing:0.12em;
  text-transform:uppercase;
}

.topbar-right{
  display:flex;
  align-items:center;
  gap:0.9rem;
}

.topbar-meta{
  font-size:0.9rem;
  opacity:0.9;
  white-space:nowrap;
}

/* Language toggle */
.lang-toggle{
  display:inline-flex;
  border:1px solid rgba(255,255,255,0.35);
  border-radius:999px;
  overflow:hidden;
}

.lang-btn{
  padding:0.35rem 0.65rem;
  font-weight:800;
  font-size:0.85rem;
  color:#fff;
  text-decoration:none;
}

.lang-btn:hover{ background:rgba(255,255,255,0.12); }
.lang-btn.active{ background:rgba(255,255,255,0.22); }

/* ======================================================
   HERO
====================================================== */
.hero{
  padding:3rem 0 2.4rem;
}

.hero-grid{
  display:grid;
  grid-template-columns:120px 1fr;
  gap:1.5rem;
}

.hero-mark{
  position:relative;
  width:120px;
  height:120px;
}

/* Decorative rings */
.ring{
  position:absolute;
  left:50%;
  transform:translateX(-50%);
  border-radius:999px;
  border:3px solid #c8d3dd;
}

.ring-1{
  top:0;
  width:110px;
  height:110px;
}

.ring-2{
  top:0;
  width:64px;
  height:64px;
  border-color:#9fb0bf;
}

.hero-title{
  font-size:2.3rem;
  line-height:1.12;
  margin:0 0 0.8rem;
}

.hero-subtitle{
  max-width:75ch;
  color:var(--muted);
  margin-bottom:1.4rem;
}

.hero-actions{
  display:flex;
  gap:0.75rem;
  flex-wrap:wrap;
}

/* ======================================================
   BUTTONS
   Subtle interactivity only — no visual noise.
====================================================== */
.btn{
  padding:0.85rem 1.1rem;
  border-radius:12px;
  font-weight:800;
  text-decoration:none;
  border:1px solid transparent;

  display:inline-flex;
  align-items:center;
  gap:0.35rem;

  transition:
    box-shadow 160ms ease,
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

.btn-primary{
  background:var(--accent);
  color:#fff;
}

.btn-primary:hover,
.btn-primary:focus-visible{
  box-shadow:0 10px 24px rgba(15,75,120,0.35);
  transform:translateY(-1px);
}

.btn-secondary{
  background:#fff;
  border-color:var(--border);
  color:var(--ink);
}

.btn-secondary:hover,
.btn-secondary:focus-visible{
  background:#f7fbff;
  border-color:#b8c7d6;
  box-shadow:0 8px 18px rgba(0,0,0,0.08);
  transform:translateY(-1px);
}

/* ======================================================
   SECTIONS & TYPOGRAPHY
====================================================== */
.section{
  padding:3.2rem 0;
}

.section-muted{
  background:var(--bg-muted);
  border-top:1px solid #e7eef6;
  border-bottom:1px solid #e7eef6;
}

/* Ensure long narrative text stays readable */
.section-muted .body{
  color:var(--ink);
}

.section-title{
  font-size:1.8rem;
  margin:0 0 1.2rem;
}

.subhead{
  margin:1.4rem 0 0.6rem;
  font-size:1.1rem;
}

.body{
  color:var(--muted);
  max-width:90ch;
  margin-bottom:1rem;
}

/* Dense methodological prose */
.method-body{
  max-width:none;
  color:#2f3f4f;
  line-height:1.65;
}

/* ======================================================
   OVERVIEW LAYOUT
====================================================== */
.section-grid{
  display:grid;
  grid-template-columns:1.6fr 1fr;
  gap:2rem;
}

/* Standard content containers */
.panel,
.callout{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:18px;
  padding:1.6rem;
  box-shadow:var(--shadow);
}

/* Legend should be flat (no elevation) */
/* .legend-panel{
  box-shadow: none;
} */

/* Normalize internal spacing inside content boxes */
.panel > :first-child,
.callout > :first-child{
  margin-top: 0;
}

.panel > :last-child,
.callout > :last-child{
  margin-bottom: 0;
}

/* Narrative panel: visually lighter, same geometry */
.panel-soft{
  background:#ffffff;
  border:1px solid #e3ebf3;
  box-shadow:none;
  padding:1.6rem;
  border-radius:18px;
}

.callout-title{
  font-size:1.2rem;
  margin-bottom:0.9rem;
}

.callout-list{
  padding-left:1.1rem;
  color:var(--muted);
}

.callout-list b{
  color:var(--ink);
}

/* ======================================================
   ABSENCE CONDITIONS
====================================================== */
.absence-section{
  margin-top:2rem;
}

.absence-section-head{
  background:#fff;
  border:1px solid var(--border);
  border-radius:14px;
  padding:0.6rem 0.9rem;
  margin-bottom:0.8rem;
}

.absence-section-title{
  font-size:1.05rem;
  font-weight:900;
}

.absence-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(240px,1fr));
  gap:1rem;
}

/* Cards */
.absence-card{
  background:#fff;
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:0 10px 22px rgba(0,0,0,0.06);
  overflow:hidden;

  transition:
    box-shadow 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.absence-card:hover{
  box-shadow:0 18px 38px rgba(0,0,0,0.10);
  border-color:#9fb6cc;
  transform:translateY(-2px);
}

/* Card header */
.absence-card-head{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  padding:0.75rem 1rem;
  background:#f9fbfd;
  border-bottom:1px solid var(--border);
}

.absence-taxon{
  font-weight:900;
  line-height:1.25;
}

/* Optional link styling (quiet, academic) */
.absence-taxon a{
  color:inherit;
  text-decoration:none;
}

.absence-taxon a:hover{
  text-decoration:underline;
}

.absence-card-body{
  padding:0.9rem 1rem 1.1rem;
}

.stars{
  font-weight:700;
  letter-spacing:0.5px;
}

#absence > .container > .subhead{
  color: var(--muted);
}

#absence > .container > .bullets{
  color: var(--muted);
}

.absence-high .absence-section-head,
.absence-medium .absence-section-head{
  box-shadow: var(--shadow);
}

/* Priority accents */
.absence-high .absence-card{ border-left:6px solid #b40000; }
.absence-medium .absence-card{ border-left:6px solid #a35a00; }

/* ======================================================
   REFERENCES
====================================================== */
#references .bullets,
#references .bullets a{
  color: var(--muted);
}

#references .body{
  color: var(--muted);
}

/* ======================================================
   SEMANTIC RULE CHIPS
====================================================== */
.absence-rules{
  display:flex;
  flex-direction:column;
  gap:0.45rem;
}

.rule-chip{
  display:flex;
  align-items:center;
  gap:0.45rem;
  padding:0.35rem 0.65rem;
  border-radius:999px;
  border:1px solid var(--border);
  font-size:0.9rem;
}

/* Semantic categories (intentionally distinct hues) */
.rule-water{
  background:#e3f0fb;
  border-color:#7fb2e5;
  color:#0f3c66;
}

.rule-chem{
  background:#f7efe6;
  border-color:#d8bfa3;
  color:#5a3e1b;
}

.rule-element{
  background:#f1f4e3;
  border-color:#c0cc8a;
  color:#3f4a16;
}

.rule-crop{
  background:#e6f4ea;
  border-color:#9fc8ab;
  color:#1f5a3a;
}

/* OR divider */
.or-divider{
  display:flex;
  align-items:center;
  gap:0.6rem;
  margin:0.6rem 0;
  font-size:0.78rem;
  font-weight:800;
  letter-spacing:0.08em;
  color:var(--muted);
}

.or-divider::before,
.or-divider::after{
  content:"";
  flex:1;
  height:1px;
  background:var(--border);
}

/* ======================================================
   LEGEND PANEL
   Reference-only visual explanation
====================================================== */

.legend-panel{
  margin: 1.6rem 0 2.2rem;
}

/* Title spacing */
.legend-title{
  margin-bottom: 1rem;
}

/* Star rows */
.legend-stars{
  display: grid;
  gap: 0.35rem;
  padding-left: 1.4rem; /* aligns visually with bullet rhythm */
  margin-bottom: 1.2rem;
  font-size: 0.95rem;
  color: var(--ink);
}

/* Individual star row */
.legend-row{
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

/* Color legend chips */
.legend-colors{
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}


/* ======================================================
   FOOTER
====================================================== */
.footer{
  border-top:1px solid #e7eef6;
  padding:1.3rem 0;
  color:#667788;
}

.footer-inner{
  display:flex;
  justify-content:space-between;
  gap:1rem;
  flex-wrap:wrap;
}

/* ======================================================
   RESPONSIVE
====================================================== */
@media (max-width:860px){
  .hero-grid{ grid-template-columns:1fr; }
  .section-grid{ grid-template-columns:1fr; }
  .absence-grid{ grid-template-columns:1fr; }
  .hero-title{ font-size:2rem; }
}
