/* Modernmama — semantic CSS.
 *
 * Every selector here targets an element, an ARIA state, or an id the document
 * already needs for navigation. The markup carries no class attribute at all:
 * when a style needs a hook, the hook is the meaning
 * (button[aria-pressed="true"], a[href="#konten"]), never an invented name.
 *
 * Reading order: tokens -> base -> layout -> site header -> hero -> topics ->
 * articles -> site footer -> a11y.
 */

/* --- tokens ------------------------------------------------------------ */

:root {
  /* `color-scheme` is the single switch for the whole theme: every token below
   * is a light-dark() pair resolved against it. Datastar sets data-tema on
   * <html>, so the toggle changes color-scheme and nothing else has to know. */
  color-scheme: light dark;

  --paper:        light-dark(#fbf8f3, #14110e);
  --paper-raised: light-dark(#ffffff, #1d1815);
  --paper-sunken: light-dark(#f4ede3, #100e0c);
  --ink:          light-dark(#241f1a, #f2ece4);
  --ink-muted:    light-dark(#5f564c, #b0a49a);
  --rule:         light-dark(#e6dccd, #2e2721);
  --accent:       light-dark(#a8452b, #e0865f);
  --accent-ink:   light-dark(#fff6f2, #1a1310);
  --accent-soft:  light-dark(#f7e4da, #35221a);
  --shadow-color: light-dark(rgb(36 31 26 / 10%), rgb(0 0 0 / 55%));

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;

  --measure: 62ch;
  --gutter: clamp(1.15rem, 4vw, 2.75rem);
  --band: clamp(2.75rem, 6.5vw, 5.25rem);
  --gap: clamp(1rem, 2.2vw, 1.5rem);
  --radius: 0.65rem;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

:root[data-tema="terang"] { color-scheme: light; }
:root[data-tema="gelap"]  { color-scheme: dark; }

/* --- base -------------------------------------------------------------- */

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

html {
  background: var(--paper);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;

  font-family: var(--font-body);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.075rem);
  line-height: 1.65;
  color: var(--ink);
  /* The warm wash lives on body, not on the hero section: a gradient clipped to
   * a section box leaves a visible straight edge where the box starts. Tinting
   * with --accent (not --accent-soft) at low alpha is what makes it perceptible
   * against the paper without turning into a highlight. */
  background:
    radial-gradient(72rem 26rem at 0% -8%,
      color-mix(in oklab, var(--accent) 13%, transparent) 0%,
      color-mix(in oklab, var(--accent) 6%, transparent) 42%,
      transparent 72%)
    no-repeat,
    var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0;
}

h1 { font-size: clamp(2.1rem, 1.35rem + 3.6vw, 4rem); }
h2 { font-size: clamp(1.45rem, 1.2rem + 1.1vw, 2rem); margin-block-end: 1.15rem; }

p {
  margin: 0 0 1rem;
  max-width: var(--measure);
  text-wrap: pretty;
}

a {
  color: var(--accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 0.06em;
}

a:hover { text-decoration-thickness: 0.12em; }

img, svg { max-width: 100%; height: auto; }

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

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

input,
button {
  font: inherit;
  color: inherit;
}

input {
  min-width: 0;
  padding: 0.72rem 0.9rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color 0.15s var(--ease);
}

input:hover { border-color: color-mix(in oklab, var(--accent) 40%, var(--rule)); }

input::placeholder { color: color-mix(in oklab, var(--ink-muted) 72%, transparent); }

label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

button {
  padding: 0.72rem 1.25rem;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s var(--ease), transform 0.12s var(--ease),
              border-color 0.15s var(--ease), color 0.15s var(--ease);
}

button:hover { background: color-mix(in oklab, var(--accent) 85%, var(--ink)); }
button:active { transform: translateY(1px); }

/* --- layout ------------------------------------------------------------ */

main > section {
  max-width: 74rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-block: var(--band) 0;
  scroll-margin-top: 4.5rem;
}

main > section:last-child { padding-block-end: var(--band); }

/* --- site header ------------------------------------------------------- */

/* Scoped to body's direct child: <header> also appears inside every <article>. */
body > header {
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem clamp(1rem, 2.5vw, 1.75rem);
  padding: 0.85rem var(--gutter);
  border-block-end: 1px solid var(--rule);
  background: color-mix(in oklab, var(--paper) 86%, transparent);
  backdrop-filter: blur(12px) saturate(1.15);
}

body > header > a {
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}

body > header nav { margin-inline-start: auto; }

body > header nav ul,
body > footer nav ul {
  display: flex;
  gap: clamp(0.9rem, 2.2vw, 1.6rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

body > header nav a {
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

body > header nav a:hover { color: var(--accent); }

body > header > button {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
}

body > header > button:hover {
  color: var(--accent);
  background: transparent;
  border-color: color-mix(in oklab, var(--accent) 55%, var(--rule));
}

/* --- hero -------------------------------------------------------------- */

hgroup { margin: 0 0 1.35rem; }

hgroup > p {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

/* The paragraph directly after the heading group is the standfirst. */
hgroup + p {
  font-size: clamp(1.06rem, 1rem + 0.55vw, 1.32rem);
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 46ch;
}

form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.6rem;
  max-width: 34rem;
  margin-block: 2rem 0;
}

form > label { flex: 1 0 100%; margin-block-end: -0.15rem; }
form > input { flex: 1 1 15rem; }
form > small { flex: 1 0 100%; font-size: 0.82rem; color: var(--ink-muted); }

/* The confirmation only exists after a submit: it is a live region, not a toast. */
form > p[role="status"] {
  flex: 1 0 100%;
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

/* --- topics ------------------------------------------------------------ */

#topik ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

#topik button {
  padding: 0.5rem 0.95rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper-raised);
  border-color: var(--rule);
}

#topik button:hover {
  background: var(--paper-raised);
  border-color: color-mix(in oklab, var(--accent) 55%, var(--rule));
  color: var(--accent);
}

/* The ARIA state is the selected state: no second source of truth. */
#topik button[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
}

#topik button[aria-pressed="true"]:hover {
  background: color-mix(in oklab, var(--accent) 85%, var(--ink));
  color: var(--accent-ink);
}

/* --- articles ---------------------------------------------------------- */

#artikel search { display: block; margin-block-end: 1.75rem; }

#artikel search form { max-width: 26rem; margin-block: 0; }
#artikel search input { flex: 1 1 100%; }

#daftar-artikel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

#daftar-artikel > li { display: flex; }

#daftar-artikel article {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  inline-size: 100%;
  padding: 1.4rem 1.5rem 1.1rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: 0 1px 2px var(--shadow-color);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease),
              border-color 0.18s var(--ease);
}

#daftar-artikel > li:hover article {
  transform: translateY(-3px);
  border-color: color-mix(in oklab, var(--accent) 35%, var(--rule));
  box-shadow: 0 1px 2px var(--shadow-color),
              0 16px 32px -20px var(--shadow-color);
}

#daftar-artikel article h3 {
  font-size: clamp(1.08rem, 1rem + 0.45vw, 1.26rem);
}

#daftar-artikel article header > p {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

#daftar-artikel article > p {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--ink-muted);
}

#daftar-artikel article > footer {
  margin-block-start: auto;
  padding-block-start: 0.45rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

#artikel > p button {
  padding: 0.5rem 0.9rem;
  font-size: 0.88rem;
  color: var(--accent);
  background: transparent;
  border-color: var(--rule);
}

#artikel > p button:hover {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
}

/* --- site footer ------------------------------------------------------- */

body > footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 1.75rem var(--gutter);
  font-size: 0.88rem;
  color: var(--ink-muted);
  background: var(--paper-sunken);
  border-block-start: 1px solid var(--rule);
}

body > footer p { margin: 0; }

body > footer nav a {
  color: var(--ink-muted);
  text-decoration: none;
}

body > footer nav a:hover { color: var(--accent); }

/* --- a11y -------------------------------------------------------------- */

/* The skip link is the only direct child link of body; it earns its selector. */
body > a[href="#konten"] {
  position: fixed;
  inset-block-start: -4rem;
  inset-inline-start: 0;
  z-index: 100;
  padding: 0.7rem 1.15rem;
  border-end-end-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-ink);
  background: var(--accent);
  transition: inset-block-start 0.15s var(--ease);
}

body > a[href="#konten"]:focus { inset-block-start: 0; }

@media (hover: none) {
  #daftar-artikel > li:hover article { transform: none; }
}

/* Narrow screens: brand and the theme button share the first row, navigation
 * takes a row of its own. Without this the button is the only thing that wraps
 * and ends up orphaned under the brand. */
@media (max-width: 40rem) {
  body > header > nav {
    order: 3;
    flex-basis: 100%;
    margin-inline-start: 0;
  }

  body > header > button { margin-inline-start: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }

  #daftar-artikel > li:hover article { transform: none; }
}
