/* james.css: James's base for new projects. Black and white, blue links, system fonts, big and plain.
   Tokens, reset, type, links and the controls we use all the time. NO page layout: no column widths,
   no page padding, no header or footer. Those belong to each project (see james-pages.css for the
   mrjamesbell.com page patterns). Layering: james.css -> project theme.css (token overrides) -> page CSS.
   Rules: text >= 14px, no horizontal scroll, 48px controls, loud status messages. */

:root {
  /* colour (light): black and white, blue links */
  --bg: #FFFFFF;
  --fg: #000000;
  --muted: #595959;         /* dates, captions, hints: 7:1 on white, 14px+ only */
  --quote: #333333;
  --card: #FFFFFF;
  --edge: #CFCFCF;          /* card ring */
  --panel: #F2F2F2;
  --panel-strong: #E3E3E3;
  --leader: #BDBDBD;
  --placeholder: #EBEBEB;
  --accent: #0B57D0;        /* link blue */
  --accent-hover: #083F99;
  --on-accent: #FFFFFF;
  --good: #0B5D2A;
  --warn: #6B4200;
  --bad: #961010;
  --field: #FFFFFF;
  --field-edge: #000000;
  /* type */
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-head: var(--font);
  --text: 20px;
  --small: 18px;            /* never below 14px */
  --body: 20px;             /* .prose writing size */
  --lead: 21px;
  --leading: 1.6;
  --h1: clamp(30px, 6vw, 40px);
  --h2: 24px;
  --h3: 20px;
  /* space and shape */
  --gap: 20px;
  --tap: 46px;              /* minimum control height */
  --page-x: 5%;             /* page margin each side: content uses 90% of the width */
  --page-y: 24px;
  --r-img: 0px; --r-btn: 0px; --r-card: 0px;      /* square; a project theme can round them */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --fg: #FFFFFF; --muted: #B3B3B3; --quote: #D9D9D9; --card: #0D0D0D; --edge: #3A3A3A;
    --panel: #1A1A1A; --panel-strong: #2B2B2B; --leader: #555555; --placeholder: #1A1A1A;
    --accent: #8AB4F8; --accent-hover: #AECBFA; --on-accent: #000000;
    --good: #7EE0A0; --warn: #FFD27A; --bad: #FF9C9C; --field: #000000; --field-edge: #FFFFFF; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --fg: #FFFFFF; --muted: #B3B3B3; --quote: #D9D9D9; --card: #0D0D0D; --edge: #3A3A3A;
  --panel: #1A1A1A; --panel-strong: #2B2B2B; --leader: #555555; --placeholder: #1A1A1A;
  --accent: #8AB4F8; --accent-hover: #AECBFA; --on-accent: #000000;
  --good: #7EE0A0; --warn: #FFD27A; --bad: #FF9C9C; --field: #000000; --field-edge: #FFFFFF; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: var(--text)/var(--leading) var(--font); overflow-x: hidden;
  padding: var(--page-y) max(var(--page-x), env(safe-area-inset-right, 0px)) var(--page-y) max(var(--page-x), env(safe-area-inset-left, 0px));
}
img, video, canvas, svg { max-width: 100%; height: auto; }
img { border-radius: var(--r-img); background: var(--placeholder); }

/* layout helpers (no widths) */
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.grid > *, .row > *, .stack > * { min-width: 0; }
.scroll-x { overflow-x: auto; }      /* only for wide tables and code */
.skip { position: absolute; left: -9999px; top: 12px; z-index: 100; background: var(--card); color: var(--fg); padding: 10px 16px; border-radius: var(--r-btn); text-decoration: underline; }
.skip:focus { left: 16px; }

/* type: hierarchy from size and weight; sans headings, serif writing */
h1, h2, h3, h4 { margin: 0; font-family: var(--font-head); font-weight: 700; line-height: 1.25; text-wrap: balance; overflow-wrap: anywhere; }
h1 { font-size: var(--h1); line-height: 1.15; letter-spacing: -.02em; }
h2 { font-size: var(--h2); } h3 { font-size: var(--h3); } h4 { font-size: var(--text); }
p { margin: 0; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
small, .small { font-size: var(--small); }
.muted { color: var(--muted); }
.label { font-size: var(--small); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.num { font-variant-numeric: tabular-nums; }
code, pre, kbd { font-family: var(--mono); font-size: var(--small); }
code { background: var(--panel); padding: 2px 5px; border-radius: var(--r-img); font-size: .9em; }
kbd { background: var(--panel); padding: 2px 6px; border-radius: var(--r-img); border: 1px solid var(--leader); }
pre { background: var(--panel); padding: 18px 20px; margin: 0; overflow-x: auto; border-radius: var(--r-btn); line-height: 1.6; }
pre code { background: none; padding: 0; font-size: inherit; }
hr { border: 0; height: 24px; margin: 0; }          /* space, not a line */
blockquote { margin: 0; padding: 0 0 0 24px; border: 0; font-style: italic; color: var(--quote); }
blockquote p + p { margin-top: 12px; }
blockquote cite { display: block; font: normal var(--small) var(--font); color: var(--muted); }
figure { margin: 0; }
figcaption, .caption { margin-top: 10px; font: var(--small)/1.5 var(--font); color: var(--muted); }

/* the writing: serif, roomy. Put .prose on any block of running text. */
.prose { font-family: var(--serif); font-size: var(--body); line-height: var(--leading); }
.prose > * { margin-block: 0 var(--gap); }
.prose > :last-child { margin-bottom: 0; }
.prose :is(h2, h3, h4) { margin-block: 40px 16px; font-family: var(--font-head); }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li > :is(ul, ol) { margin-block: 6px 0; }
.prose .lead { font-size: var(--lead); line-height: 1.55; }
.prose :is(p, li, blockquote, figcaption) { overflow-wrap: break-word; }
.prose figure { margin-block: 32px; }
.prose blockquote { margin-block: 32px; }

/* arrows: CSS masks inherit the text colour. .arrow-r / .arrow-l = this site; a.ext = another site */
.arrow-r::after, .arrow-l::before, a.ext::after {
  content: ""; display: inline-block; width: 10px; height: 10px; background: currentColor; opacity: .6;
  -webkit-mask: var(--a) center/contain no-repeat; mask: var(--a) center/contain no-repeat;
}
.arrow-r::after { --a: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 5H8.5M6 2.5L8.5 5L6 7.5'/%3E%3C/svg%3E"); margin-left: 5px; }
.arrow-l::before { --a: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8.5 5H1.5M4 2.5L1.5 5L4 7.5'/%3E%3C/svg%3E"); margin-right: 5px; }
a.ext::after { --a: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7L7 3M3.5 3H7V6.5'/%3E%3C/svg%3E"); width: 9px; height: 9px; margin-left: 4px; vertical-align: 1px; }

/* surfaces: a card has an edge ring (no shadow); a panel is a soft fill */
.card, .panel { background: var(--card); box-shadow: 0 0 0 1px var(--edge); border-radius: var(--r-card); padding: 24px 28px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel { background: var(--panel); box-shadow: none; }
.panel.strong { background: var(--panel-strong); }
@media (max-width: 480px) { .card, .panel { padding: 20px; } }

/* controls */
button, .btn {
  min-height: var(--tap); padding: 10px 20px; font: 400 var(--text)/1.2 var(--font);
  background: var(--fg); color: var(--bg); border: 2px solid var(--fg); border-radius: var(--r-btn); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
button.secondary, .btn.secondary { background: transparent; color: var(--fg); border-color: var(--fg); }
button.secondary:hover, .btn.secondary:hover { background: var(--fg); border-color: var(--fg); color: var(--bg); }
button.danger, .btn.danger { background: var(--bad); border-color: var(--bad); color: var(--bg); }
button:disabled { background: var(--panel-strong); border-color: var(--panel-strong); color: var(--fg); cursor: not-allowed; text-decoration: line-through; }
label { font-weight: 700; display: block; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; font: var(--text)/1.4 var(--font);
  background: var(--field); color: var(--fg); border: 2px solid var(--field-edge); border-radius: var(--r-btn);
}
/* Safari ignores min-height/padding on native selects, so draw them like the inputs */
select {
  appearance: none; -webkit-appearance: none; height: var(--tap); padding-block: 0; padding-right: 44px;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg) 50%), linear-gradient(135deg, var(--fg) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
textarea { min-height: 8rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: 24px; min-height: 24px; accent-color: var(--accent); }
input[type="color"] { padding: 4px; }
input[type="range"] { min-height: 32px; padding: 0; border: 0; background: none; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; min-height: 32px; margin: 0; }
.hint { font-size: var(--small); color: var(--muted); }
progress { appearance: none; -webkit-appearance: none; width: 100%; height: 24px; border: 2px solid var(--field-edge); border-radius: var(--r-btn); background: var(--field); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--field); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
.badge-box { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; background: var(--panel); border-radius: var(--r-btn); font-weight: 700; font-size: var(--small); }

/* tabs: a row of buttons, the current one filled (aria-current="true") */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs button { background: transparent; color: var(--fg); }
.tabs button[aria-current="true"] { background: var(--fg); color: var(--bg); }
.tabs button:hover { background: var(--panel-strong); border-color: var(--fg); color: var(--fg); }
.tabs button[aria-current="true"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }

/* disclosure: <details class="disclosure"><summary>Title</summary><div>...</div></details> */
.disclosure { background: var(--panel); border-radius: var(--r-card); }
.disclosure > summary { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 8px 16px; cursor: pointer; list-style: none; font-weight: 700; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: ""; flex: none; width: 10px; height: 10px; border-right: 3px solid var(--fg); border-bottom: 3px solid var(--fg); transform: rotate(-45deg); transition: transform .15s; }
.disclosure[open] > summary::before { transform: rotate(45deg); }
.disclosure > :not(summary) { padding: 4px 16px 16px; }

/* status and toast: loud, never colour alone (always carries a word) */
.status { padding: 12px 16px; font-weight: 700; border-left: 6px solid currentColor; background: var(--panel); border-radius: 0 var(--r-btn) var(--r-btn) 0; }
.status.good { color: var(--good); } .status.warn { color: var(--warn); } .status.bad { color: var(--bad); }
.status.bad::before { content: "Error: "; } .status.warn::before { content: "Warning: "; } .status.good::before { content: "OK: "; }
.toast { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px; background: var(--card); box-shadow: 0 0 0 1px var(--edge); border-radius: var(--r-btn); font-weight: 700; }

/* dialog */
dialog { max-width: min(560px, 94vw); border: 0; border-radius: var(--r-card); background: var(--card); color: var(--fg); padding: 24px; box-shadow: 0 0 0 1px var(--edge); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }

/* photo tiles: square crop, selected = thick accent outline, small status chip */
.photo-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(var(--tile, 140px), 1fr)); }
.photo { position: relative; aspect-ratio: 1; margin: 0; padding: 0; min-height: 0; border: 0; border-radius: var(--r-img); background: var(--placeholder); overflow: hidden; display: block; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.photo[aria-pressed="true"] { outline: 6px solid var(--accent); outline-offset: -6px; }
.photo .chip { position: absolute; left: 6px; bottom: 6px; font: 700 12px/1.3 var(--font); padding: 1px 6px; background: var(--bg); color: var(--fg); border-radius: var(--r-img); }

/* tables: bold header, banded rows, no rules */
table { border-collapse: collapse; width: 100%; font: 16px/1.5 var(--font); font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 700; padding: 8px 12px; border-bottom: 2px solid var(--fg); }
td { padding: 8px 12px; }
tbody tr:nth-child(even) { background: var(--panel); }
[hidden] { display: none !important; } /* component display rules must not defeat the hidden attribute */
