/* A shared, warm palette for the archive and the stories it links to. */
:root {
  --color-background: #faf6ed;
  --color-surface: #fffefa;
  --color-text: #292d28;
  --color-muted: #58665b;
  --color-accent: #27563f;
  --color-accent-hover: #173d2a;
  --color-border: #deded0;
  --color-subtle: #f1f0e5;
  --color-terracotta: #a84f30;
  --color-gold: #e6bd68;
  --color-focus: #946100;
  --color-tagline: #f8e7c0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
               Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  line-height: 1.65;
  font-size: 16px;
  background: var(--color-background);
  color: var(--color-text);
}

html[data-theme="brown"] {
  --color-background: #edc397;
  --color-surface: #fff1da;
  --color-text: #351809;
  --color-muted: #60371f;
  --color-accent: #58250f;
  --color-accent-hover: #381608;
  --color-border: #986039;
  --color-subtle: #f5d5ad;
  --color-terracotta: #863a14;
  --color-gold: #f3ad5d;
  --color-focus: #713008;
  --color-tagline: #ffd59f;
}
html[data-theme="black-tan"] {
  --color-background: #f3dcc0;
  --color-surface: #fff6e8;
  --color-text: #160e09;
  --color-muted: #593721;
  --color-accent: #100c09;
  --color-accent-hover: #652c10;
  --color-border: #975526;
  --color-subtle: #eab579;
  --color-terracotta: #80380e;
  --color-gold: #e9a454;
  --color-focus: #7e340d;
  --color-tagline: #ffbb6c;
}
html[data-theme="husky"] {
  --color-background: #fff;
  --color-surface: #fff;
  --color-text: #000;
  --color-muted: #404040;
  --color-accent: #000;
  --color-accent-hover: #262626;
  --color-border: #000;
  --color-subtle: #eee;
  --color-terracotta: #262626;
  --color-gold: #fff;
  --color-focus: #000;
  --color-tagline: #fff;
}

* { box-sizing: border-box; }
body { margin: 0; }

/* Post pages use this same stylesheet without changing their saved HTML. */
article {
  max-width: 850px;
  margin: 2.5rem auto;
  padding: clamp(1.5rem, 5vw, 3.75rem);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: 0 12px 38px rgba(41, 45, 40, .06);
  border-radius: 1rem;
  overflow-wrap: break-word;
}
h1, h2, h3, h4, h5 {
  line-height: 1.2;
  font-weight: 700;
  margin-top: 1.5em;
  margin-bottom: .5em;
}
article h1, article h2, article h3 { font-family: Georgia, "Times New Roman", serif; color: var(--color-accent); }
article h1 { font-size: clamp(2rem, 5vw, 3rem); margin-top: 0; }
.post-date { color: var(--color-muted); font-size: .9rem; margin-bottom: 2rem; }
a, re-link { color: var(--color-accent); text-decoration: underline; text-underline-offset: .18em; }
a:hover, re-link:hover { color: var(--color-terracotta); }
a:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
p { margin: 1em 0; }
ul, ol { margin: 1em 0; padding-left: 1.5em; }
li { margin: .25em 0; }
img { max-width: 100%; height: auto; border-radius: .5rem; }
pre { background: var(--color-subtle); padding: 1em; overflow-x: auto; border-radius: .5rem; }
code { font-family: "Courier New", Courier, monospace; background: var(--color-subtle); padding: .2em .4em; border-radius: 3px; }
pre code { padding: 0; }
blockquote { border-left: 4px solid var(--color-gold); margin: 1.5em 0; padding: .5em 1em; color: var(--color-muted); background: var(--color-subtle); }

/* Homepage */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--color-accent); color: #fffefa; border-bottom: 5px solid var(--color-gold); }
.site-header-inner { max-width: 1080px; margin: 0 auto; padding: 1.5rem; display: flex; align-items: end; justify-content: space-between; gap: 1rem 2rem; }
.site-brand { display: flex; align-items: center; gap: 1.2rem; min-width: 0; }
.site-mark { width: 64px; height: 64px; flex: none; border: 3px solid rgba(255, 254, 250, .8); border-radius: 50%; }
.site-header h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.035em; line-height: 1.05; margin: 0; }
.site-tagline { margin: .4rem 0 0; color: var(--color-tagline); font-size: .95rem; letter-spacing: .025em; }
main { max-width: 1080px; margin: 0 auto; padding: 2.75rem 1.5rem 4rem; }
.visually-hidden, #status[data-state="results"] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.header-controls { display: grid; gap: .55rem; justify-items: end; flex: none; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .65rem; }
.write-link { border: 1px solid currentColor; border-radius: .45rem; padding: .2rem .75rem; color: #fff; font-weight: 700; text-decoration: none; }
.write-link:hover, .write-link:focus-visible { color: #fff; text-decoration: underline; outline-color: #fff; }
.theme-picker { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; }
.theme-button { width: 30px; height: 30px; padding: 0; border: 2px solid #fffefa; border-radius: 50%; cursor: pointer; }
.theme-button[aria-pressed="true"] { outline: 2px solid var(--color-gold); outline-offset: 2px; }
.theme-button:focus-visible { outline: 3px solid #fffefa; outline-offset: 3px; }
.theme-green { background: #27563f; }
.theme-brown { background: #b96d36; }
.theme-black-tan { background: linear-gradient(135deg, #100c09 50%, #e9a454 50%); }
.theme-husky { background: linear-gradient(135deg, #000 50%, #fff 50%); }
.archive-filters { display: flex; flex-wrap: wrap; gap: .8rem; flex: none; }
.archive-filters[hidden] { display: none; }
.archive-filters label { display: block; font-size: .8rem; font-weight: 700; color: var(--color-accent); }
.archive-filters select { font: inherit; font-size: .95rem; min-width: 9rem; max-width: 100%; padding: .5rem 2rem .5rem .7rem; color: var(--color-text); background: var(--color-surface); border: 1px solid #becabc; border-radius: .45rem; }
#status { color: var(--color-muted); font-size: .88rem; padding: .4rem 0; }
ul#posts { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.post { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 1.4rem; border: 1px solid var(--color-border); border-radius: 1rem; padding: .9rem; margin: 0; transition: box-shadow .15s ease, transform .15s ease; background: var(--color-surface); }
.post:hover { box-shadow: 0 10px 28px rgba(41, 45, 40, .09); transform: translateY(-2px); }
.thumb { width: 100%; height: 150px; object-fit: cover; border-radius: .65rem; background: var(--color-subtle); }
.post > div { align-self: center; min-width: 0; padding: .25rem .5rem .25rem 0; }
.meta { font-size: .82rem; color: var(--color-muted); margin: .4rem 0; }
.title { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.45rem; line-height: 1.2; }
.title a { text-decoration: none; }
.title a:hover { text-decoration: underline; }
.tags { font-size: .75rem; font-weight: 700; letter-spacing: .025em; color: var(--color-terracotta); margin-bottom: .45rem; overflow-wrap: anywhere; }
.post p { margin: .6rem 0 0; color: var(--color-muted); }
.site-footer { text-align: center; color: var(--color-accent); background: var(--color-subtle); border-top: 1px solid var(--color-border); padding: 2rem 1rem; font-family: Georgia, "Times New Roman", serif; font-style: italic; }
.site-footer span { color: var(--color-terracotta); padding: 0 .5rem; font-style: normal; }
html[data-theme] .archive-filters select { border-color: var(--color-border); }
html[data-theme] .archive-filters select:focus-visible { outline-color: var(--color-tagline); }
html[data-theme="husky"] .site-header { color: #fff; }
html[data-theme="husky"] :is(.post, article) { border-width: 2px; box-shadow: none; }
html[data-theme="husky"] blockquote { border-color: #000; }
html[data-theme="husky"] :is(.site-footer, .site-footer span) { color: #fff; }
html[data-theme="husky"] .site-footer { background: #000; }
@media (min-width: 641px) and (max-width: 800px) {
  .site-header-inner { flex-wrap: wrap; }
  .header-controls { margin-left: auto; }
}
@media (max-width: 640px) {
  .site-header-inner { padding: .85rem 1rem; align-items: flex-start; flex-direction: column; gap: .7rem; }
  .site-brand { gap: .8rem; }
  .site-mark { width: 52px; height: 52px; }
  .header-controls { width: 100%; }
  .archive-filters { width: 100%; gap: .5rem; }
  .archive-filters label { flex: 1 1 0; min-width: 0; }
  .archive-filters select { width: 100%; min-width: 0; }
  main { padding: 2rem 1rem 3rem; }
  .post { grid-template-columns: 1fr; gap: .75rem; }
  .thumb { height: 200px; }
  .post > div { padding: 0 .25rem .35rem; }
  article { margin: 0 auto; border-radius: 0; border-left: 0; border-right: 0; }
}
@media (max-height: 400px) { .site-header { position: static; } }
@media (prefers-reduced-motion: reduce) { .post { transition: none; } .post:hover { transform: none; } }

.post-comments {
  margin-top: 2.75rem; padding-top: 1.25rem; border-top: 1px solid var(--color-border);
  scroll-margin-top: 1.25rem;
}
.comments-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .65rem 1rem; }
.post-comments h2 { margin: 0; color: var(--color-accent); font: 700 clamp(1.5rem, 4vw, 1.875rem)/1.2 Georgia, "Times New Roman", serif; }
.post-comments ol { list-style: none; padding: 0; margin: 1rem 0 0; }
.post-comments li { margin: 0; padding: 1rem 0; border-top: 1px solid var(--color-border); overflow-wrap: anywhere; }
.post-comments li:last-child { padding-bottom: 0; }
.comment-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: .15rem .75rem; }
.comment-meta strong { color: var(--color-accent); }
.comment-meta :is(time, .comment-source) { color: var(--color-muted); font-size: .85rem; }
.post-comments li p { white-space: pre-wrap; overflow-wrap: anywhere; margin: .3rem 0 0; }
.post-comments label { display: block; font-weight: 600; margin: 0 0 .85rem; }
.post-comments label span, #comment-email-help { color: var(--color-muted); font-size: .9rem; font-weight: 400; }
.post-comments input, .post-comments textarea {
  display: block; width: min(100%, 36rem); font: inherit; font-weight: 400; padding: .55rem .7rem; margin-top: .25rem;
  color: var(--color-text); background: var(--color-surface); border: 1px solid var(--color-muted); border-radius: .4rem;
}
/* Shared controls for authoring and reader comments. */
:is(.author-main, .post-comments) button {
  min-height: 48px; min-width: 48px; font: inherit; font-weight: 600;
  padding: .45rem .8rem; border-radius: .5rem; border: 1px solid var(--color-muted);
  color: var(--color-text); background: var(--color-surface); cursor: pointer;
}
:is(.author-main, .post-comments) :is(.form-primary, .author-primary) {
  color: #fff; background: var(--color-accent); border-color: var(--color-accent);
}
:is(.author-main, .post-comments) button:not([aria-disabled="true"]):hover { text-decoration: underline; }
:is(.author-main, .post-comments) button[aria-disabled="true"] { cursor: wait; }
:is(.author-main, .post-comments) :is(button, input, textarea, select, summary, a):focus-visible {
  outline: 3px solid var(--color-focus); outline-offset: 2px;
}
:is(.author-main, .post-comments) .form-status { color: var(--color-muted); }
:is(.author-main, .post-comments) .form-error { color: var(--color-terracotta); }
:is(.author-main, .post-comments) :is(.form-status, .form-error):empty { margin: 0; }
.author-main .form-error[id$="-error"]:not([role]) { margin: -.6rem 0 1rem; }
.author-main [aria-invalid="true"] { border-color: var(--color-terracotta); }
#comment-composer { margin-top: 1rem; padding: clamp(.85rem, 4vw, 1.25rem); border-radius: .75rem; background: var(--color-subtle); }
#comment-composer button { margin: .1rem .25rem .1rem 0; }
#comment-composer textarea { resize: vertical; }
#comments-empty { color: var(--color-muted); margin: .85rem 0 0; }
.post-comments li:focus { outline: 3px solid var(--color-focus); outline-offset: 3px; }
.post-comments button:disabled { opacity: .65; cursor: default; }
