/* stylesheet.org — a small, standards-compliant CSS framework.
 *
 * Semantic HTML + a handful of utility classes. No custom tags, no IDs, no
 * JavaScript. Write a normal page (header / main / footer, one h1 in main,
 * sections by depth) and it looks right; reach for a class only where HTML has
 * no element for the job (layout and a few presentational components).
 *
 * The file is in five sections. A theme only ever changes section 2.
 *   1. RESET          — constant
 *   2. THEME TOKENS   — :root variables (colour, type, space, shape)
 *   3. LAYOUT         — constant: row, column, grid, flow, stretch
 *   4. ELEMENTS       — constant: semantic tags styled directly
 *   5. COMPONENTS     — constant: panel, card, chip, buttons, status, paging, menu
 *
 * Layout model: children of .row / .column take their natural size and stack
 * from the start — a fixed item is just a width/height, no class. .stretch is
 * the one flexing element (empty = a spacer; with content = a flexible region;
 * .stretch-2 / .stretch-3 weight the shares).
 */

/* ============================================================
   1. RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg, video { max-width: 100%; height: auto; display: block; }

/* ============================================================
   2. THEME TOKENS  — the only section a theme changes  (sunshine yellow)
   ============================================================ */
:root {
  /* colour — markdown.org blue */
  --bg: #e9f1fd;               /* light blue page base — the "rest of the areas" */
  --surface: #ffffff;          /* white panels & cards */
  --surface-soft: #eef4fe;     /* nested panels / soft fills */
  --section-bg: #e9f1fd;       /* sections blend into the page */
  --header-bg: #ffffff;        /* clean white menu bar */
  --header-bg-2: #f3f7fe;      /* paler band for the stacked sub-nav */
  --fg: #1a1f29;
  --heading: #0c1320;
  --muted: #5b6472;
  --border: #d9e3f4;
  --border-strong: #c3d2ea;
  --accent: #3b6ef6;           /* markdown.org blue — buttons, links, active */
  --accent-hover: #2f5fe0;
  --accent-fg: #ffffff;
  --accent-tint: #e4ecfe;      /* light blue — hovers, focus, quotes */
  --accent-2: #0ea5a4;         /* teal — for "free" chips/badges */
  --accent-2-tint: #e2f7f6;
  --code-bg: #0f1830;          /* dark navy code block */
  --code-fg: #d6deeb;
  --ok-fg: #04603e; --ok-bg: #e9fbf2; --ok-bd: #a6e9c8;
  --err-fg: #ad1b14; --err-bg: #fdf0ef; --err-bd: #f6c9c6;
  --info-fg: #3531c7; --info-bg: #ecebfe; --info-bd: #c8c5fb;
  --warn-fg: #9a5a05; --warn-bg: #fff7e8; --warn-bd: #f6dca0;
  /* type */
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  /* space + shape */
  --space: 18px;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --maxw: 1040px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.07);
  --shadow-md: 0 6px 14px -4px rgba(16, 24, 40, 0.12), 0 2px 6px -2px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 20px 30px -12px rgba(16, 24, 40, 0.18);
}

/* ============================================================
   3. LAYOUT  — structure only; references --space, never colour
   ============================================================ */
.row, .column { display: flex; gap: var(--space); }
.row { flex-direction: row; }
.column { flex-direction: column; }
.row > *, .column > * { flex: 0 0 auto; min-width: 0; min-height: 0; }   /* natural size, from the start */
.stretch { flex: 1 1 0; min-width: 0; min-height: 0; }                    /* eats / shares the remainder */
.stretch-2 { flex-grow: 2; }
.stretch-3 { flex-grow: 3; }
.grid { display: grid; gap: var(--space); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.flow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ============================================================
   4. ELEMENTS  — semantic tags styled directly
   ============================================================ */
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
}

/* typography */
h1, h2, h3, h4, h5, h6 { color: var(--heading); font-weight: 700; line-height: 1.2; letter-spacing: -0.015em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; letter-spacing: -0.01em; }
h4 { font-size: 1.02rem; letter-spacing: 0; }
h5, h6 { font-size: 0.9rem; letter-spacing: 0; }
a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
strong { font-weight: 650; color: var(--heading); }
small { color: var(--muted); font-size: 0.875em; }
ul, ol { padding-left: 1.4em; }
li { margin: 5px 0; }
li::marker { color: var(--accent); }
hr { border: none; border-top: 1px solid var(--border); }
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-soft); border: 1px solid var(--border); padding: 0.1em 0.4em; border-radius: 6px; }
pre { background: var(--code-bg); color: var(--code-fg); border-radius: var(--radius-sm); padding: 16px 18px; overflow-x: auto; box-shadow: var(--shadow-sm); font-size: 0.85rem; line-height: 1.6; }
pre code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }
blockquote { padding: 10px 18px; border-left: 3px solid var(--accent); background: var(--accent-tint); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--fg); }

/* header: the site chrome — a bright sunshine-yellow menu, sticky, stacked bars */
header {
  position: sticky; top: 0; z-index: 10;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.06);
}
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
nav > a, nav > span { font-weight: 700; color: var(--heading); letter-spacing: -0.01em; }   /* a bar's title */
nav > a:hover { text-decoration: none; }
nav > ul { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 0; padding: 0; list-style: none; }
nav > ul > li { margin: 0; }
nav ul a { display: block; padding: 7px 13px; border-radius: 8px; white-space: nowrap; color: var(--fg); font-size: 0.95rem; font-weight: 500; text-decoration: none; transition: background 0.15s, color 0.15s; }
nav ul a:hover { background: rgba(0, 0, 0, 0.07); color: var(--heading); text-decoration: none; }
nav a[aria-current] { background: var(--accent); color: #fff; }
nav a[aria-current]:hover { background: var(--accent); color: #fff; }
header > nav { padding: 12px 28px; }
header > nav:first-of-type > a { font-size: 1.1rem; }                         /* brand */
header > nav:first-of-type > ul { margin-left: auto; }                        /* brand left, links right */
header > nav ~ nav { border-top: 1px solid rgba(0, 0, 0, 0.08); background: var(--header-bg-2); padding-top: 9px; padding-bottom: 9px; }
header > nav ~ nav > span { font-size: 0.85rem; color: var(--accent-hover); text-transform: uppercase; letter-spacing: 0.05em; }
header > nav ~ nav ul a { font-size: 0.9rem; }

/* nav dropdowns (no JS): a nested <ul> in <details> (click) or bare (hover/focus) */
nav li { position: relative; }
nav li > ul, nav details > ul {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 210px; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
}
nav li > ul li, nav details > ul li { margin: 0; }
nav summary { display: block; padding: 7px 13px; border-radius: 8px; cursor: pointer; color: var(--fg); font-size: 0.95rem; font-weight: 500; list-style: none; }
nav summary:hover { background: rgba(0, 0, 0, 0.07); color: var(--heading); }
nav summary::-webkit-details-marker { display: none; }
nav summary::after { content: "  ▾" / ""; color: var(--muted); }
nav details[open] > summary { background: rgba(0, 0, 0, 0.07); color: var(--heading); }
nav details[open] > summary::after { content: "  ▴" / ""; }
nav li:has(> ul) > a::after { content: "  ▾" / ""; color: var(--muted); }
nav li > ul { visibility: hidden; opacity: 0; transform: translateY(-4px); transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s; }
nav li:hover > ul, nav li:focus-within > ul { visibility: visible; opacity: 1; transform: none; }

/* main: a white intro with a warm radial glow; sections sit on pale yellow */
main {
  flex: 1 0 auto;                /* grow to fill: footer sticks to the bottom, pushed down by tall content */
  width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 40px 28px;
  display: flex; flex-direction: column; gap: 30px;
  background: radial-gradient(115% 75% at 50% -8%, #d6e6fb, var(--bg) 55%);
}
main > h1 { font-size: clamp(1.9rem, 4vw, 2.5rem); letter-spacing: -0.025em; line-height: 1.12; }
main > h1 + p { max-width: 72ch; font-size: 1.15rem; color: var(--muted); }
/* a top-level feature list (e.g. the homepage goals): roomy, a lead line each */
main > ul { padding-left: 1.3em; max-width: 70ch; }
main > ul > li { margin: 0 0 18px; }
main > ul > li:last-child { margin-bottom: 0; }
main > ul > li > strong { font-size: 1.05rem; }
main > ul > li > p { margin-top: 4px; color: var(--muted); }

/* sections: pale-yellow blocks; bare headings; spacing tightens with depth */
section { display: flex; flex-direction: column; gap: 16px; }
main > section { background: transparent; padding: 0; }
main > section > h2 { padding-bottom: 8px; border-bottom: 2px solid var(--border-strong); }
section section { gap: 12px; border-left: 2px solid var(--border-strong); padding-left: 22px; }
section section section { gap: 9px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
caption { text-align: left; padding: 8px 0; font-weight: 600; color: var(--muted); }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
thead th { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-soft); border-bottom: 1px solid var(--border-strong); }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--accent-tint); }
tbody tr:last-child td { border-bottom: none; }

/* forms */
form { display: grid; gap: 15px; }
fieldset { padding: 16px; display: grid; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
legend { font-weight: 600; padding: 0 6px; color: var(--heading); }
label > p { font-weight: 550; font-size: 0.9rem; margin-bottom: 6px; color: var(--heading); }
input, select, textarea { width: 100%; padding: 9px 12px; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); transition: border-color 0.15s, box-shadow 0.15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; margin-right: 7px; accent-color: var(--accent); }

/* buttons (the element) + link buttons */
button, input[type="submit"], input[type="reset"], input[type="button"], a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  width: auto; padding: 9px 18px; font: inherit; font-weight: 550; line-height: 1.4;
  cursor: pointer; text-align: center; text-decoration: none;
  background: var(--accent); color: var(--accent-fg);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
button:hover, input[type="submit"]:hover, input[type="button"]:hover, a.button:hover {
  background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg);
  box-shadow: var(--shadow-md); text-decoration: none; transform: translateY(-1px);
}
/* button variants */
.button.secondary, input[type="reset"], button.secondary { background: var(--surface); color: var(--fg); border-color: var(--border-strong); box-shadow: none; }
.button.secondary:hover, input[type="reset"]:hover, button.secondary:hover { background: var(--surface-soft); color: var(--fg); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.button.ghost, button.ghost { background: transparent; color: var(--accent); border-color: transparent; box-shadow: none; }
.button.ghost:hover, button.ghost:hover { background: var(--accent-tint); color: var(--accent-hover); }
.button.small, button.small { padding: 5px 12px; font-size: 0.9rem; }
.button.large, button.large { padding: 12px 24px; font-size: 1.05rem; }

/* menu: a sidebar nav */
menu { display: block; margin: 0; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
menu ol, menu ul { list-style: none; margin: 0; padding: 0; }
menu li { margin: 2px 0; }
menu p { margin: 12px 8px 4px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
menu a { display: block; padding: 7px 12px; color: var(--fg); border-radius: 8px; transition: background 0.15s; }
menu a:hover { background: var(--surface-soft); text-decoration: none; }
menu a[aria-current] { background: var(--accent-tint); color: var(--accent-hover); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }

/* ============================================================
   5. COMPONENTS
   ============================================================ */
/* panel — a soft surface; card — a panel that's a unit / clickable */
.panel, .card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.panel .panel, .card .card { background: var(--surface-soft); box-shadow: none; }
.card { transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.12s ease; }
a.card { color: inherit; }
a.card:hover, .grid > a.card:hover { text-decoration: none; box-shadow: var(--shadow-md); border-color: var(--accent); transform: translateY(-2px); }
.card > h2, .card > h3 { color: var(--accent); }

/* chip — an inline pill label; a button/a chip is interactive */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; font-size: 0.85rem; font-weight: 550; line-height: 1.5; color: var(--fg); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); }
button.chip, a.chip { cursor: pointer; text-decoration: none; transition: background 0.15s, border-color 0.15s, color 0.15s; }
button.chip:hover, a.chip:hover { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-hover); text-decoration: none; }
.chip.accent { background: var(--accent-tint); border-color: transparent; color: var(--accent-hover); }
.chip.teal { background: var(--accent-2-tint); border-color: transparent; color: var(--accent-2); }

/* buttons — a group of actions */
.buttons { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* status — a banner / live region */
.status { display: block; padding: 11px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-weight: 500; }
.status.success { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-fg); }
.status.error   { background: var(--err-bg); border-color: var(--err-bd); color: var(--err-fg); }
.status.info    { background: var(--info-bg); border-color: var(--info-bd); color: var(--info-fg); }
.status.warning { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn-fg); }

/* paging — a Pagination nav */
.paging { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.paging a, .paging span { display: inline-block; padding: 7px 13px; border-radius: 8px; color: var(--fg); text-decoration: none; }
.paging a:hover { background: var(--surface); box-shadow: var(--shadow-sm); text-decoration: none; }
.paging a[aria-current] { background: var(--accent); color: var(--accent-fg); }
.paging span { color: var(--muted); }

/* footer: a full-width bar like the header */
footer { flex-shrink: 0; width: 100%; padding: 24px 28px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); }
footer a { color: var(--muted); text-decoration: underline; }

/* ============================================================
   6. markdown.org ADDITIONS — local extras the framework does not cover yet.
   ============================================================ */

/* Homepage hero — a full-bleed darker-blue band (no hero component upstream). */
.hero {
  background:
    radial-gradient(900px 480px at 80% -30%, rgba(86, 134, 255, 0.45), transparent 60%),
    linear-gradient(160deg, #16223d 0%, #0d1526 55%, #0a0f1e 100%);
  color: #eaf1fb;
  border-bottom: 1px solid var(--border-strong);
}
.hero-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: clamp(44px, 8vw, 84px) 28px;
  display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center;
}
.hero h1 { color: #fff; font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -0.03em; line-height: 1.08; }
.hero p { color: #aab9d0; max-width: 56ch; font-size: 1.15rem; }
.hero .buttons { justify-content: center; }
.hero .button.secondary { background: rgba(255, 255, 255, 0.08); color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.hero .button.secondary:hover { background: rgba(255, 255, 255, 0.16); color: #fff; border-color: rgba(255, 255, 255, 0.35); }

/* Logo tiles inside tool / library cards. */
.logo { width: 34px; height: 34px; flex: none; border-radius: 8px; object-fit: contain; background: #fff; padding: 3px; border: 1px solid var(--border); }
.logo.letter { display: grid; place-items: center; background: var(--accent); color: var(--accent-fg); border: none; padding: 0; font: 700 1rem/1 var(--mono); }

/* "You write / you get" example label. */
.example small { display: block; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; font-size: 0.72rem; }

/* Home cards: a button CTA pinned to the bottom, so equal-height cards line up. */
.card:has(.card-cta) { display: flex; flex-direction: column; gap: 12px; }
.card-cta { margin-top: auto; align-self: start; }

/* Mobile fallback: the framework's fixed column grids don't collapse yet. */
@media (max-width: 560px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* Offset in-page anchors so they clear the sticky (two-bar) header. */
html { scroll-padding-top: 7rem; }
