:root {
  --ink: #111;
  --ink-soft: #555;
  --ink-faint: #666;
  --accent: #8a5a24;
  --ground: #fff;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --ink: #e8e0d6;
    --ink-soft: #b3aa9f;
    --ink-faint: #8f877d;
    --accent: #d4a574;
    --ground: #0d0907;
  }
}

html[data-theme="dark"] {
  --ink: #e8e0d6;
  --ink-soft: #b3aa9f;
  --ink-faint: #8f877d;
  --accent: #d4a574;
  --ground: #0d0907;
}

.site-header {
  width: 100%;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  color: var(--ink);
}

.site-header a {
  display: inline-flex;
}

.site-header .wordmark {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: normal;
  line-height: 1;
  color: inherit;
  text-decoration: none;
  flex-shrink: 0;
}

.site-header .wordmark:hover {
  opacity: 1;
}

.site-header nav {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.site-header nav a {
  font-family: 'Inter', sans-serif;
  font-size: 20px;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--ink-soft);
}

.site-header nav a:hover {
  opacity: 0.7;
}

.site-header nav a.current {
  color: var(--ink);
}

.site-header.dark {
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
}

.site-header.dark nav a {
  color: rgba(255, 255, 255, 0.68);
}

.site-header.dark nav a.current {
  color: #fff;
}

.site-header.dark .wordmark {
  color: #fff;
}

/* Gallery grids: the count line under each gallery title ("47 pictures →") */
.gallery-item .gallery-caption {
  font-size: 17px;
}

.gallery-door-count {
  margin: 4px 2px 0;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 1.35;
  color: rgba(232, 224, 214, 0.72);
  text-decoration: none;
}

.gallery-item:hover .gallery-door-count {
  color: rgba(232, 224, 214, 0.95);
}

.site-footer {
  background: #111;
  color: #fff;
  padding: 40px 32px;
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  opacity: 0.7;
}

.site-footer .wordmark {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: normal;
  line-height: 1;
  color: #fff;
  text-decoration: none;
  display: block;
  margin-bottom: 8px;
}

.site-footer .wordmark:hover {
  opacity: 1;
}

.site-footer .footer-altered {
  font-family: 'Lora', serif;
  font-size: 15px;
  color: #999;
  margin: 0 0 32px;
}

.site-footer nav {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.site-footer nav a {
  font-size: 16px;
  color: #999;
}

.site-footer p.footer-contact {
  font-size: 16px;
  color: #999;
  margin: 0 0 16px;
}

.site-footer p.footer-contact a {
  color: #FFB000;
  margin-left: 16px;
}

.site-footer p.footer-contact a:hover {
  color: #ffc23d;
  text-decoration: underline;
}

.site-footer p:last-child {
  font-size: 16px;
  color: #999;
  margin: 0;
}

.gallery-eyebrow {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.6;
  margin: 0 0 8px;
}

.gallery-eyebrow a {
  color: inherit;
  text-decoration: none;
}

.gallery-eyebrow a:hover {
  opacity: 0.7;
}

.gallery-door-count {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  letter-spacing: 0.03em;
  opacity: 0.6;
  margin: 4px 0 0;
}

@media (max-width: 800px) {
  .site-header {
    flex-direction: column;
    gap: 16px;
  }

  .site-header a {
    justify-content: center;
  }

  .site-header nav {
    justify-content: center;
    text-align: center;
    row-gap: 10px;
  }
}

@media (max-width: 600px) {
  .site-footer {
    padding: 32px 20px;
  }
  .site-header .wordmark,
  .site-footer .wordmark {
    font-size: 24px;
  }
}

/* ==========================================================================
   Theme strip: a thin bar above the header with the date and the
   Light / Dark / Auto choice. Scrolls away with the page (not pinned).
   ========================================================================== */

.theme-strip {
  box-sizing: border-box;
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  color: var(--ink-faint);
}

.theme-strip .theme-date-short {
  display: none;
}

.theme-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.theme-choice {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--ink-faint);
  cursor: pointer;
}

.theme-choice:hover {
  opacity: 0.7;
}

.theme-choice[data-active="true"] {
  color: var(--ink-soft);
}

.theme-dot {
  color: var(--ink-faint);
}

@media (max-width: 800px) {
  .theme-strip {
    padding: 0 16px;
  }
}

@media (max-width: 360px) {
  .theme-strip .theme-date-full {
    display: none;
  }

  .theme-strip .theme-date-short {
    display: inline;
  }
}

/* ==========================================================================
   Dark mode
   html[data-theme="dark"]  -> forced dark
   html[data-theme="light"] -> forced light (no rules needed; site default)
   no attribute             -> Auto, follows prefers-color-scheme
   Colors are the ones the site's existing dark pages already use:
   ground #0d0907, reading/caption type rgba(232,224,214,.9), small grey
   type rgba(232,224,214,.6), faint white hairline rgba(255,255,255,.18).
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body,
  html:not([data-theme="light"]) .work-body {
    background: var(--ground);
    color: var(--ink);
  }
}

html[data-theme="dark"] body,
html[data-theme="dark"] .work-body {
  background: var(--ground);
  color: var(--ink);
}

/* Header: light-header pages take the dark header's look. Pages already
   using .site-header.dark are unaffected (rule below matches either). */
html[data-theme="dark"] .site-header {
  background: transparent;
  color: var(--ink);
  border-bottom-color: rgba(255, 255, 255, 0.18);
}
html[data-theme="dark"] .site-header nav a {
  color: var(--ink-soft);
}
html[data-theme="dark"] .site-header nav a.current {
  color: var(--ink);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .site-header {
    background: transparent;
    color: var(--ink);
    border-bottom-color: rgba(255, 255, 255, 0.18);
  }
  html:not([data-theme="light"]) .site-header nav a {
    color: var(--ink-soft);
  }
  html:not([data-theme="light"]) .site-header nav a.current {
    color: var(--ink);
  }
}

/* CSS-variable based pages (writings.html and anything else that reads
   --white / --text from HISTORY-ASSEMBLED/history.css). */
html[data-theme="dark"] {
  --white: var(--ground);
  --text: var(--ink);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --white: var(--ground);
    --text: var(--ink);
  }
}

/* Front door (public/index.html): cream ground + dark ink swap to the
   same near-black / off-white as everywhere else. The blue-to-sage rule
   under the header (.home-rule) is untouched. */
html[data-theme="dark"] .home-heading,
html[data-theme="dark"] .home-title,
html[data-theme="dark"] .home-everything {
  color: var(--ink);
}
html[data-theme="dark"] .home-eyebrow,
html[data-theme="dark"] .home-readon a {
  color: var(--ink-soft);
}
html[data-theme="dark"] .home-readon a:hover,
html[data-theme="dark"] .home-title a:hover,
html[data-theme="dark"] .home-everything:hover {
  color: var(--ink);
}
html[data-theme="dark"] .home-passage p,
html[data-theme="dark"] .home-overture,
html[data-theme="dark"] .home-tagline,
html[data-theme="dark"] .home-door {
  color: var(--ink);
}
html[data-theme="dark"] .home-passage,
html[data-theme="dark"] .home-passage:first-of-type {
  border-color: rgba(255, 255, 255, 0.18);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .home-heading,
  html:not([data-theme="light"]) .home-title,
  html:not([data-theme="light"]) .home-everything {
    color: var(--ink);
  }
  html:not([data-theme="light"]) .home-eyebrow,
  html:not([data-theme="light"]) .home-readon a {
    color: var(--ink-soft);
  }
  html:not([data-theme="light"]) .home-readon a:hover,
  html:not([data-theme="light"]) .home-title a:hover,
  html:not([data-theme="light"]) .home-everything:hover {
    color: var(--ink);
  }
  html:not([data-theme="light"]) .home-passage p,
  html:not([data-theme="light"]) .home-overture,
  html:not([data-theme="light"]) .home-tagline,
  html:not([data-theme="light"]) .home-door {
    color: var(--ink);
  }
  html:not([data-theme="light"]) .home-passage,
  html:not([data-theme="light"]) .home-passage:first-of-type {
    border-color: rgba(255, 255, 255, 0.18);
  }
}

/* Individual picture pages (works.css .work-body family) and similar
   light-shell pages (e.g. public/wander): secondary text, hairlines and
   swapped-color buttons. */
html[data-theme="dark"] .work-credit,
html[data-theme="dark"] .work-nav-arrow,
html[data-theme="dark"] .work-nav-count,
html[data-theme="dark"] .work-fact-label,
html[data-theme="dark"] .work-row-label,
html[data-theme="dark"] .work-tile-catnum,
html[data-theme="dark"] .wander-caption,
html[data-theme="dark"] .wander-links a {
  color: var(--ink-soft);
}
html[data-theme="dark"] .work-fact-value,
html[data-theme="dark"] .work-tile-caption,
html[data-theme="dark"] .wander-title,
html[data-theme="dark"] .wander-body p {
  color: var(--ink);
}
html[data-theme="dark"] .work-nav-arrow:hover,
html[data-theme="dark"] .work-nav-arrow:focus-visible {
  color: var(--ink);
  outline-color: rgba(232, 224, 214, 0.95);
}
html[data-theme="dark"] .work-row {
  border-top-color: rgba(255, 255, 255, 0.18);
}
html[data-theme="dark"] .work-row-hairline-track {
  background: rgba(255, 255, 255, 0.18);
}
html[data-theme="dark"] .work-row-hairline-thumb {
  background: rgba(232, 224, 214, 0.6);
}
html[data-theme="dark"] .work-row-hairline-thumb:hover,
html[data-theme="dark"] .work-row-hairline.wrh-dragging .work-row-hairline-thumb {
  background: rgba(232, 224, 214, 0.9);
}
html[data-theme="dark"] .work-fullscreen-link {
  background: var(--ground);
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.18);
}
html[data-theme="dark"] .work-fullscreen-link:hover,
html[data-theme="dark"] .work-fullscreen-link:focus-visible {
  background: #e8e0d6;
  color: #0d0907;
}
html[data-theme="dark"] .wander-another {
  background: #e8e0d6;
  color: #0d0907;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .work-credit,
  html:not([data-theme="light"]) .work-nav-arrow,
  html:not([data-theme="light"]) .work-nav-count,
  html:not([data-theme="light"]) .work-fact-label,
  html:not([data-theme="light"]) .work-row-label,
  html:not([data-theme="light"]) .work-tile-catnum,
  html:not([data-theme="light"]) .wander-caption,
  html:not([data-theme="light"]) .wander-links a {
    color: var(--ink-soft);
  }
  html:not([data-theme="light"]) .work-fact-value,
  html:not([data-theme="light"]) .work-tile-caption,
  html:not([data-theme="light"]) .wander-title,
  html:not([data-theme="light"]) .wander-body p {
    color: var(--ink);
  }
  html:not([data-theme="light"]) .work-nav-arrow:hover,
  html:not([data-theme="light"]) .work-nav-arrow:focus-visible {
    color: var(--ink);
    outline-color: rgba(232, 224, 214, 0.95);
  }
  html:not([data-theme="light"]) .work-row {
    border-top-color: rgba(255, 255, 255, 0.18);
  }
  html:not([data-theme="light"]) .work-row-hairline-track {
    background: rgba(255, 255, 255, 0.18);
  }
  html:not([data-theme="light"]) .work-row-hairline-thumb {
    background: rgba(232, 224, 214, 0.6);
  }
  html:not([data-theme="light"]) .work-row-hairline-thumb:hover,
  html:not([data-theme="light"]) .work-row-hairline.wrh-dragging .work-row-hairline-thumb {
    background: rgba(232, 224, 214, 0.9);
  }
  html:not([data-theme="light"]) .work-fullscreen-link {
    background: var(--ground);
    color: var(--ink);
    border-color: rgba(255, 255, 255, 0.18);
  }
  html:not([data-theme="light"]) .work-fullscreen-link:hover,
  html:not([data-theme="light"]) .work-fullscreen-link:focus-visible {
    background: #e8e0d6;
    color: #0d0907;
  }
  html:not([data-theme="light"]) .wander-another {
    background: #e8e0d6;
    color: #0d0907;
  }
}

html[data-theme="dark"] .theme-strip {
  border-bottom-color: rgba(255, 255, 255, 0.18);
  color: var(--ink-faint);
}
html[data-theme="dark"] .theme-choice {
  color: var(--ink-faint);
}
html[data-theme="dark"] .theme-choice[data-active="true"] {
  color: var(--ink);
}
html[data-theme="dark"] .theme-dot {
  color: var(--ink-faint);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-strip {
    border-bottom-color: rgba(255, 255, 255, 0.18);
    color: var(--ink-faint);
  }
  html:not([data-theme="light"]) .theme-choice {
    color: var(--ink-faint);
  }
  html:not([data-theme="light"]) .theme-choice[data-active="true"] {
    color: var(--ink);
  }
  html:not([data-theme="light"]) .theme-dot {
    color: var(--ink-faint);
  }
}

/* ==========================================================================
   Light mode
   html[data-theme="light"]  -> forced light
   no attribute + light device -> Auto, follows prefers-color-scheme
   These override the fixed-dark inline styles that the gallery grids
   (physical.html, marks.html, digital.html, mind-mapping/index.html) and
   every gallery folder page beneath them carry in their own <style>
   block, plus the .site-header.dark variant those pages use. Individual
   picture pages (works.css .work-body) are already light by default and
   need no rules here. Specificity (html[data-theme] ancestor) is needed
   to beat the pages' own same-specificity inline body {} / .gallery-*
   rules, matching how the Dark section above beats them the other way.
   ========================================================================== */

html[data-theme="light"] body {
  background: var(--ground);
  color: var(--ink);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) body {
    background: var(--ground);
    color: var(--ink);
  }
}

/* Header: dark-header pages take the light header's look in Light. */
html[data-theme="light"] .site-header.dark {
  background: transparent;
  border-bottom-color: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .site-header.dark nav a {
  color: var(--ink-soft);
}
html[data-theme="light"] .site-header.dark nav a.current {
  color: var(--ink);
}
html[data-theme="light"] .site-header.dark .wordmark {
  color: var(--ink);
}
html[data-theme="light"] .site-header.dark.is-pinned {
  background: var(--ground);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .site-header.dark {
    background: transparent;
    border-bottom-color: rgba(0, 0, 0, 0.12);
  }
  html:not([data-theme="dark"]) .site-header.dark nav a {
    color: var(--ink-soft);
  }
  html:not([data-theme="dark"]) .site-header.dark nav a.current {
    color: var(--ink);
  }
  html:not([data-theme="dark"]) .site-header.dark .wordmark {
    color: var(--ink);
  }
  html:not([data-theme="dark"]) .site-header.dark.is-pinned {
    background: var(--ground);
  }
}

/* Gallery grid captions ("47 pictures →" grids' .gallery-caption is the
   primary reading type), gallery-folder descriptive copy (.gallery-words)
   and catalogue numbers (.gallery-tile-catnum), and the shared count line
   (.gallery-door-count, chrome.css above). */
html[data-theme="light"] .gallery-caption,
html[data-theme="light"] .gallery-title-block h1 {
  color: var(--ink);
}
html[data-theme="light"] .gallery-words,
html[data-theme="light"] .gallery-tile-catnum,
html[data-theme="light"] .gallery-door-count,
html[data-theme="light"] .section-heading {
  color: var(--ink-faint);
}
html[data-theme="light"] .gallery-item:hover .gallery-door-count {
  color: var(--ink);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .gallery-caption,
  html:not([data-theme="dark"]) .gallery-title-block h1 {
    color: var(--ink);
  }
  html:not([data-theme="dark"]) .gallery-words,
  html:not([data-theme="dark"]) .gallery-tile-catnum,
  html:not([data-theme="dark"]) .gallery-door-count,
  html:not([data-theme="dark"]) .section-heading {
    color: var(--ink-faint);
  }
  html:not([data-theme="dark"]) .gallery-item:hover .gallery-door-count {
    color: var(--ink);
  }
}

/* marks.html's "Also by hand" / "Inspirations" / "Experiences" lines
   below its gallery grid carry their color as an inline style attribute
   (no class to hook), so beating it in Light needs !important. */
html[data-theme="light"] .gallery-grid ~ p[style] {
  color: var(--ink-soft) !important;
}
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .gallery-grid ~ p[style] {
    color: var(--ink-soft) !important;
  }
}

/* ==========================================================================
   Header return: the header pins to the top and slides in when the
   visitor scrolls up, after having scrolled past it. The theme strip is
   not part of this and stays unpinned.
   ========================================================================== */

.site-header-spacer {
  height: 0;
}

.site-header.is-pinned {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  transform: translateY(0);
  transition: transform 200ms ease;
  box-shadow: none;
}

.site-header.is-pinned.is-hidden {
  transform: translateY(-100%);
}

.site-header.is-pinned {
  background: var(--ground);
}

.site-header.dark.is-pinned {
  background: #0d0907;
}

html[data-theme="dark"] .site-header.is-pinned {
  background: var(--ground);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .site-header.is-pinned {
    background: var(--ground);
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-header.is-pinned {
    transition: none;
  }
}
