/* Backbenchineer — a small, dependency-free stylesheet. Light & dark via prefers-color-scheme. */

:root {
  color-scheme: light;
  --bg: #fcfcfb;
  --surface: #ffffff;
  --surface-2: #f3f2ef;
  --border: #e3e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7973;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --danger: #c23b3a;
  --success: #1d7a45;
  --warning-bg: #fff6e0;
  --radius: 10px;
  --max: 1120px;
  --prose: 70ch;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #34332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9a998f;
    --accent: #3987e5;
    --warning-bg: #3a2f12;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.6 var(--font);
  background: var(--bg);
  color: var(--text);
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.01em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); font-size: .9rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }
.prose-width { max-width: var(--prose); }
main { padding: 2rem 0 4rem; min-height: 70vh; }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.site-header .container { display: flex; align-items: center; gap: 1.5rem; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; flex: none; border-radius: 6px; }
.nav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.nav a { color: var(--text-2); text-decoration: none; font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); }
.nav-right { margin-left: auto; display: flex; gap: .9rem; align-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-2); display: inline-grid; place-items: center; font-weight: 600; color: var(--text-2); font-size: .85rem; }
.avatar.lg { width: 96px; height: 96px; font-size: 2rem; }
.badge { display: inline-block; min-width: 1.3em; padding: 0 .4em; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.5; }
.bell { position: relative; text-decoration: none; color: var(--text-2); font-size: 1.15rem; }
.bell .badge { position: absolute; top: -6px; right: -10px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 2rem 0; color: var(--muted); font-size: .875rem; }
.site-footer .container { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }
.site-footer a { color: var(--muted); }

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.messages li { padding: .75rem 1rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: .5rem; }
.messages .success { border-color: var(--success); }
.messages .error { border-color: var(--danger); }

/* ---------- Buttons & forms ---------- */
.btn, button { display: inline-flex; align-items: center; gap: .45rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover, button:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }
.btn-link { border: 0; background: none; color: var(--accent); padding: 0; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

label { display: block; font-weight: 600; margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=url], input[type=password], input[type=search],
input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: .6rem .7rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { margin-bottom: 1.1rem; }
.field .helptext, .helptext { display: block; color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.field.checkbox label { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: .25rem 0; font-size: .9rem; }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-body { padding: 1rem 1.15rem; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a:hover { color: var(--accent); }
.cover { aspect-ratio: 3 / 2; object-fit: cover; width: 100%; background: var(--surface-2); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 2.5rem 0 1rem; }
.section-head h2 { margin: 0; }
.hero { padding: 1.5rem 0 1rem; }
.hero p { font-size: 1.2rem; color: var(--text-2); }

.tags { display: flex; gap: .4rem; flex-wrap: wrap; padding: 0; margin: .5rem 0; list-style: none; }
.tag { display: inline-block; font-size: .8rem; padding: .1rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--text-2); text-decoration: none; border: 1px solid var(--border); }
.tag:hover { color: var(--text); }
.meta { color: var(--muted); font-size: .9rem; }

/* ---------- Article ---------- */
.article-header { max-width: var(--prose); margin-bottom: 2rem; }
.article-cover { margin: 0 0 2rem; border-radius: var(--radius); overflow: hidden; }
.content-warning { max-width: var(--prose); background: var(--warning-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1.5rem; }
.prose { max-width: var(--prose); font-family: var(--serif); font-size: 1.15rem; line-height: 1.75; }
.prose h2, .prose h3 { font-family: var(--font); margin-top: 2em; }
.prose img { border-radius: 6px; margin: 1.5em 0; }
.prose blockquote { margin: 1.5em 0; padding-left: 1.2em; border-left: 3px solid var(--border); color: var(--text-2); }
.prose pre { font-family: var(--mono); font-size: .9rem; background: var(--surface-2); padding: 1rem; border-radius: 8px; overflow-x: auto; }
.prose code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .3em; border-radius: 4px; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; font-family: var(--font); font-size: .95rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: .4rem .7rem; }
.community-body { font-size: 1rem; line-height: 1.65; max-width: var(--prose); }
.community-body p:first-child { margin-top: 0; }

/* ---------- Reactions ---------- */
.reactions { display: flex; gap: .35rem; flex-wrap: wrap; margin: 1.25rem 0; }
.reaction { padding: .25rem .6rem; border-radius: 999px; font-size: .95rem; background: var(--surface); border: 1px solid var(--border); line-height: 1.4; }
.reaction .count { font-size: .8rem; color: var(--text-2); font-variant-numeric: tabular-nums; margin-left: .15rem; }
.reaction.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.reaction.htmx-request { opacity: .6; }

/* ---------- Gallery ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .6rem; }
.photo-grid a { display: block; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; transition: transform .25s ease; }
.photo-grid a:hover img { transform: scale(1.02); }
.photo-stage { background: #0b0b0b; margin: 0 calc(50% - 50vw); padding: 1.5rem 0; }
.photo-stage img { max-height: 86vh; width: auto; margin: 0 auto; }
.photo-nav { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0; gap: 1rem; }
.exif { display: flex; gap: 1.25rem; flex-wrap: wrap; color: var(--text-2); font-size: .9rem; padding: 0; list-style: none; }

/* ---------- Community ---------- */
.topic-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--border); }
.topic-list li { display: flex; gap: 1rem; align-items: center; padding: .9rem 0; border-bottom: 1px solid var(--border); }
.topic-list .topic-main { flex: 1; min-width: 0; }
.topic-list .topic-title { font-weight: 600; color: var(--text); text-decoration: none; }
.topic-list .topic-title:hover { color: var(--accent); }
.topic-stats { text-align: right; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.pill { font-size: .75rem; padding: 0 .5rem; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); }
.post-item { display: flex; gap: 1rem; padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.post-item.hidden-item { opacity: .55; }
.post-author { display: flex; gap: .6rem; align-items: center; margin-bottom: .5rem; }
.post-author a { font-weight: 600; color: var(--text); text-decoration: none; }
.discussion-panel { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); max-width: var(--prose); }
.notice { background: var(--surface-2); border-radius: var(--radius); padding: .9rem 1rem; }

/* ---------- Notifications ---------- */
.notification-list { list-style: none; padding: 0; margin: 0; }
.notification-list li a { display: block; padding: .8rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.notification-list li.unread a { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); font-weight: 600; }

/* ---------- Auth ---------- */
.auth-box { max-width: 420px; margin: 1rem auto; }
.social-buttons { display: grid; gap: .6rem; margin: 1.5rem 0; }
.social-buttons button { width: 100%; justify-content: center; padding: .75rem 1rem; font-size: 1rem; }
details.owner-login summary { cursor: pointer; color: var(--muted); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 1rem; justify-content: center; margin-top: 2rem; align-items: center; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th { text-align: left; font-weight: 600; color: var(--text-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.data th, table.data td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Fixes */
main { overflow-x: clip; } /* full-bleed photo stage must not cause horizontal scroll */
.post-author a.meta { font-weight: 400; color: var(--muted); text-decoration: none; }

/* ---------- Home page ---------- */
.hero-home { padding: 3.5rem 0 2.5rem; }
.hero-home h1 { font-size: clamp(2.2rem, 6vw, 4rem); line-height: 1.08; letter-spacing: -.03em; margin-bottom: 1.25rem; }
.hero-home .lead { font-size: clamp(1.1rem, 1.6vw, 1.45rem); color: var(--text-2); margin: 0 0 1.75rem; } /* flows to the full page width */
.btn-lg { padding: .8rem 1.4rem; font-size: 1.05rem; }

/* ---------- Section page headers (Blog, Community, Studio) ---------- */
.page-hero { padding: 2.25rem 0 1.25rem; }
.page-hero h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); line-height: 1.1; letter-spacing: -.025em; margin-bottom: 1rem; }
.page-hero .lead { font-size: clamp(1.05rem, 1.4vw, 1.3rem); color: var(--text-2); margin: 0 0 1.5rem; }
.page-hero .btn-row:empty { display: none; }

/* ---------- Sharing work in Studio ---------- */
.work-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 2.5rem; align-items: start; }
@media (max-width: 900px) { .work-layout { grid-template-columns: 1fr; } }
.panel-box { border: 1px dashed var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; margin-bottom: 1rem; background: var(--surface); }
.work-photos figure { margin: 0; position: relative; }
.work-photos figure form { position: absolute; top: .4rem; right: .4rem; }
button[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Comments and replies (two levels, ADR-0019) ---------- */
.comments { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); max-width: var(--prose); }
.comment-thread { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.comment { padding: .25rem 0; }
.comment .reactions { margin: .6rem 0 .25rem; }
.comment-replies { margin: .75rem 0 0 1.25rem; padding-left: 1rem; border-left: 2px solid var(--border); }
.comment-replies .comment { padding: .6rem 0; }
.comment-actions { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: flex-start; color: var(--muted); }
.comment-actions a, .comment-actions .btn-link { color: var(--muted); font-size: inherit; }
.reply-box summary { cursor: pointer; color: var(--accent); list-style: none; }
.reply-box summary::-webkit-details-marker { display: none; }
.reply-box[open] { flex-basis: 100%; }
.reply-box form { margin-top: .5rem; display: grid; gap: .5rem; justify-items: start; }
.reply-box textarea { width: 100%; }
.comment-form { margin-top: 1.5rem; display: grid; gap: .4rem; justify-items: start; }
.comment-form textarea { width: 100%; }
@media (max-width: 600px) { .comment-replies { margin-left: .5rem; padding-left: .75rem; } }
.post-item + .comments { border-top: 0; margin-top: .5rem; padding-top: 0; }
