/* Base: typography, browser surfaces, links, buttons, status chips, the no-JS floor (role A3).
   PLAN §7.2, §7.5, §7.6, §12.2, §14. The engine stylesheet loads first; this file overrides its floor. */

/* ---- no-JS and failed-engine floor (§12.2, verbatim) --------------------- */
html:is(.no-js, .sc-failed) :is([data-sc-cue], [data-sc-in], [data-sc-stagger] > *) { opacity: 1 !important; transform: none !important; }
/* keyboard focus never lands on a block that is still waiting for its reveal */
:is([data-sc-in], [data-sc-stagger] > *):focus-within { opacity: 1 !important; transform: none !important; transition: none !important; }
html:is(.no-js, .sc-failed) [data-sc-reveal] { clip-path: none !important; }
/* without JS these buttons would do nothing (contents drawer, language switch) */
html.no-js :is(.head__toc, .head__lang, .head__lang-toggle) { display: none !important; }
html.lang-pending :is([data-i18n], [data-i18n-html]) { visibility: hidden; }

[hidden] { display: none !important; }

/* ---- document ------------------------------------------------------------ */
html { background: var(--paper); }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--t-body);
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: 0.003em;
  font-synthesis: none;
}
:is(h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote) { margin: 0; }
:is(ul, ol) { padding: 0; }
:is(h1, h2, h3) { font-family: var(--font-display); font-weight: 300; text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
strong, b { font-weight: 700; }
em, i { font-style: italic; }
table { border-collapse: collapse; }
:is(table, output, .tabular) { font-variant-numeric: tabular-nums; }
img { height: auto; }
sub { font-size: 0.72em; vertical-align: -0.18em; line-height: 0; }
abbr[title] { text-decoration: underline dotted; text-underline-offset: 0.2em; cursor: help; }

/* ---- browser surfaces (§7.5) --------------------------------------------- */
::selection { background: var(--forest-tint); color: var(--ink); }
:root { caret-color: var(--forest); accent-color: var(--forest); }
@supports (scrollbar-color: auto) {
  html { scrollbar-color: var(--ink-faint) transparent; scrollbar-width: thin; }
}
:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 3px;
  border-radius: var(--r);
}
:focus:not(:focus-visible) { outline: none; }
:is(a, button, input, textarea, select, summary) { scroll-margin-top: calc(var(--head-h) + var(--s-5)); scroll-margin-bottom: var(--s-7); }

/* ---- type roles (§7.2) --------------------------------------------------- */
.h2, .h3 { font-family: var(--font-display); font-weight: 300; text-wrap: balance; }
.h2 {
  font-size: var(--t-h2);
  line-height: 1.08;
  letter-spacing: -0.022em;
  color: var(--ink);
}
.h3 {
  font-size: var(--t-h3);
  line-height: 1.2;
  letter-spacing: -0.012em;
}
.lede {
  font-size: var(--t-lede);
  line-height: 1.5;
  max-width: 40ch;
  color: var(--ink-2);
}
.prose > * + * { margin-top: var(--s-4); }
.prose { max-width: var(--measure); }
.caption {
  font-size: var(--t-caption);
  font-style: italic;
  line-height: 1.5;
  color: var(--ink-soft);
}
.note { font-size: var(--t-note); line-height: 1.55; color: var(--ink-soft); }
.u { white-space: nowrap; }
/* a bound figure (a range such as US$15–20, Rp 2,5 juta, 2.500–5.000) never breaks across lines */
span[data-fmt] { white-space: nowrap; }

/* ---- links ------------------------------------------------------------- */
a {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-color: var(--forest);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: text-decoration-thickness var(--d-hover) var(--ease-out), color var(--d-hover) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  a:hover { color: var(--forest); text-decoration-thickness: 2px; }
}
.link-go {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: var(--t-ui);
  line-height: 1.2;
  min-height: 44px;
}
.link-go .icon { transition: transform var(--d-hover) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .link-go:hover .icon { transform: translateX(3px); }
}

/* ---- icons (Lucide sprite) --------------------------------------------- */
.icon {
  display: inline-block;
  flex: none;
  width: 1.125em;
  height: 1.125em;
  vertical-align: -0.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--ext { width: 0.875em; height: 0.875em; vertical-align: -0.08em; }

/* ---- accessibility helpers --------------------------------------------- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: fixed;
  z-index: 100;
  top: var(--s-2);
  left: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background: var(--forest);
  color: var(--paper);
  font: 500 var(--t-ui)/1.2 var(--font-ui);
  text-decoration: none;
  border-radius: var(--r);
  transform: translateY(-200%);
}
.skip:focus, .skip:focus-visible { transform: none; outline-color: var(--ink); }

/* ---- status chips (§7.6) ----------------------------------------------- */
.status {
  position: relative;
  display: inline-block;
  padding-left: calc(8px + 0.375rem);
  vertical-align: baseline;
  text-align: left;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: var(--t-label);
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  font-style: normal;
  white-space: normal;
}
.status__mark {
  position: absolute;
  left: 0;
  top: calc(0.65em - 4px);
  display: block;
  width: 8px;
  height: 8px;
  color: currentColor;
  fill: currentColor;
  stroke: none;
}
.status__basis { white-space: normal; }
/* an external rule (Plan Vivo minimum) carries its basis only: no mark, no status (review r3) */
.status--rule { padding-left: 0; }

/* source links next to chips */
.src {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: var(--t-label);
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  font-style: normal;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  margin-top: var(--s-3);
}

/* ---- buttons (§7.5) ---------------------------------------------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0.625rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--r);
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: var(--t-ui);
  line-height: 1.2;
  letter-spacing: 0.005em;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--d-hover) var(--ease-out),
    border-color var(--d-hover) var(--ease-out),
    color var(--d-hover) var(--ease-out),
    transform var(--d-press) var(--ease-out);
}
.btn:active { transform: scale(0.98); }
.btn .icon { width: 1rem; height: 1rem; vertical-align: 0; }
.btn--primary { background: var(--forest); color: var(--paper); border-color: var(--forest); }
.btn--secondary { background: var(--paper); color: var(--ink); border-color: var(--ink); }
.btn--text {
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--forest);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  justify-content: flex-start;
  text-align: left;
}
.btn--compact { min-height: 40px; padding: 0.5rem 0.875rem; }
.btn--compact::before { content: ""; position: absolute; inset: -2px 0; }
.btn--on-forest { background: var(--paper); color: var(--forest); border-color: var(--paper); }
.btn--on-forest-outline { background: transparent; color: var(--paper); border-color: var(--paper); }
.btn--on-forest-text {
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--paper);
  text-decoration: underline;
  text-decoration-color: var(--forest-on-dark);
  text-underline-offset: 0.18em;
}
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { background: var(--forest-press); border-color: var(--forest-press); color: var(--paper); }
  .btn--secondary:hover { background: var(--forest-tint); color: var(--ink); }
  .btn--text:hover { color: var(--forest); text-decoration-thickness: 2px; }
  .btn--on-forest:hover { background: var(--forest-tint); color: var(--forest-press); }
  .btn--on-forest-outline:hover { background: var(--rule-on-dark); color: var(--paper); }
  .btn--on-forest-text:hover { text-decoration-thickness: 2px; color: var(--paper); }
}
.btn--primary:active { background: var(--forest-press); }

/* ---- dark grounds (ch. 11 ink, ch. 12 forest, footer) ----------------- */
:is([data-ground="ink"], [data-ground="forest"], .foot) {
  color: var(--paper);
  --rule: var(--rule-on-dark);
  line-height: 1.72;
  letter-spacing: 0.01em;
}
:is([data-ground="ink"], [data-ground="forest"], .foot) :is(.h2, .h3, .lede) { color: var(--paper); }
:is([data-ground="ink"], [data-ground="forest"], .foot) a { color: var(--paper); text-decoration-color: var(--forest-on-dark); }
@media (hover: hover) and (pointer: fine) {
  :is([data-ground="ink"], [data-ground="forest"], .foot) a:hover { color: var(--forest-on-dark); }
  :is([data-ground="ink"], [data-ground="forest"], .foot) a.btn--on-forest:hover { color: var(--forest-press); }
}
:is([data-ground="ink"], [data-ground="forest"], .foot) :is(.status, .src, .caption, .note) { color: var(--paper-on-dark-soft); }
:is([data-ground="ink"], [data-ground="forest"], .foot) :focus-visible { outline-color: var(--forest-on-dark); }
:is([data-ground="ink"], [data-ground="forest"], .foot) ::selection { background: var(--forest-on-dark); color: var(--ink-ground); }
:is([data-ground="ink"], [data-ground="forest"], .foot) .btn--on-forest { color: var(--forest); }

/* ---- motion ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .btn, a, .link-go .icon { transition-duration: 0ms; }
  .btn:active { transform: none; }
}
