/* Soft daylight paper and a forest-green evening archive. */
:root {
  color-scheme: light;
  --backdrop: #5e705f;
  --outer-ink: #e9ecdf;
  --paper: #e8ecdd;
  --ink: #29382e;
  --red: #536d4e;
  --tab-two: #dce3d0;
  --tab-three: #d0dac6;
  --tab-four: #c4d0b9;
  --paper-edge: #c8d3bd;
  --paper-back: #aebda3;
  --rule: #84977b73;
  --muted: #53634e;
  --print: #f2f1e5;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --backdrop: #121715;
  --outer-ink: #e3e8db;
  --paper: #1c2420;
  --ink: #e9ecdf;
  --red: #b7caa5;
  --tab-two: #2c3730;
  --tab-three: #263029;
  --tab-four: #222b26;
  --paper-edge: #39463a;
  --paper-back: #2e3930;
  --rule: #b0c4a040;
  --muted: #b7c2b0;
  --print: #2e3930;
}
html { scrollbar-gutter: stable; }
body { background-color: var(--backdrop); }
.masthead, .rail, .page-footer { color: var(--outer-ink); }
.folder-tab { background-color: var(--paper-edge); }
.folder-tab:nth-child(2) { background-color: var(--tab-two); }
.folder-tab:nth-child(3) { background-color: var(--tab-three); }
.folder-tab:nth-child(4) { background-color: var(--tab-four); }
.folder-tab[aria-current="page"] { background-color: var(--paper); }
.folder-body {
  box-shadow: 9px 6px 18px #101a132b,
    18px 7px 0 -2px var(--paper-edge),
    33px 19px 0 -9px var(--paper-back),
    -11px 10px 0 -3px var(--paper-edge);
}
.folder-footer { color: var(--muted); border-color: var(--rule); }
.front-photo, .project-print:not(.scout-print) { background: var(--print); }
.project-peeks, .background-details, .article-files, .article-file,
.visual-case-copy details { border-color: var(--rule); }
.article-index small { color: var(--muted); }
[data-theme="dark"] .folder-body,
[data-theme="dark"] .folder-tab,
[data-theme="dark"] .folder-tab[aria-current="page"]:after { background-blend-mode: multiply; }
[data-theme="dark"] .big-link img,
[data-theme="dark"] .small-link img,
[data-theme="dark"] .peek-arrow,
[data-theme="dark"] .article-file > img:not(.article-thumb) { filter: invert(92%) sepia(14%) saturate(260%); }
/* The wordmark and theme button share real layout space, without scaling over neighbours. */
.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16%;
  gap: 24px;
  align-items: center;
  height: auto;
  padding: 20px 0 12px;
  container-type: inline-size;
}
.wordmark {
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  font-size: clamp(48px, 20cqi, 270px);
  line-height: .9;
  letter-spacing: -.075em;
  transform: none;
}
.theme-toggle {
  position: relative;
  justify-self: center;
  top: clamp(0px, 2.3vw, 36px);
  display: block;
  width: 52px;
  height: 52px;
  padding: 0;
  margin: 0;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
  color: var(--outer-ink);
  cursor: pointer;
  overflow: hidden;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:focus-visible { outline: 3px solid var(--outer-ink); outline-offset: 5px; }
.theme-toggle:hover { background: #ffffff12; }
.theme-toggle img {
  position: absolute;
  inset: 13px;
  width: 24px;
  height: 24px;
  filter: invert(95%);
  transition: transform .25s ease, opacity .2s ease;
}
.theme-toggle .theme-sun { opacity: 0; transform: rotate(-90deg) scale(.5); }
.theme-toggle[aria-pressed="true"] .theme-moon { opacity: 0; transform: rotate(90deg) scale(.5); }
.theme-toggle[aria-pressed="true"] .theme-sun { opacity: 1; transform: rotate(0) scale(1); }
.archive-hint { color: var(--outer-ink); font-size: 11px; line-height: 1.6; margin: 0 1.2% 18px; }
/* Normal document flow keeps the instruction visible on short or narrow displays. */
.rail { top: 300px; bottom: auto; }
.case-heading h1 { white-space: normal; overflow-wrap: break-word; transform: none; }
.front-copy, .visual-case-copy, .article-file>div { min-width: 0; }
.big-link { flex-wrap: wrap; }
.big-link img { flex-shrink: 0; }
:focus-visible { scroll-margin-block: 20px; }
::selection { background: var(--red); color: var(--paper); }
@media(max-width:1100px) { .rail { display: none; } }
@media(max-width:700px) {
  .masthead { margin: 0 6% 18px; padding-top: 24px; grid-template-columns: minmax(0, 1fr) 44px; gap: 12px; }
  .wordmark { font-size: 19cqi; line-height: 1; }
  .theme-toggle { width: 44px; height: 44px; top: 0; }
  .theme-toggle img { inset: 9px; }
  .archive-hint { font-size: 10px; margin-bottom: 14px; }
  .folder-body { box-shadow: 5px 4px 12px #101a132b, 10px 5px 0 -3px var(--paper-edge), -5px 7px 0 -3px var(--paper-edge); }
}
@media(prefers-reduced-motion:reduce) { .theme-toggle img { transition: none; } }
/* The selected tab overlaps the sheet, including its rounded top edge. */
.folder-tab[aria-current="page"]::after { bottom: -20px; height: 22px; }
.case:focus { outline: none; }
/* The real article is already mounted beneath this non-interactive paper cover. */
.opening-cover {
  position: fixed;
  z-index: 15;
  pointer-events: none;
  overflow: hidden;
  box-shadow: none;
  will-change: transform;
  transform-origin: center bottom;
  backface-visibility: hidden;
}
.opening-cover .case { animation: none !important; }
.casebook-reading .rail { display: none; }

.socials { flex-wrap: wrap; gap: 16px 25px; }
.socials .small-link img { width: 19px; height: 19px; }

/* Every tab meets the same paper baseline; selection changes its height, not its position. */
.folder-tabs { min-height: 69px; align-items: end; gap: 0; }
.folder-tabs .folder-tab:nth-child(n) { transform: none; height: 61px; min-height: 61px; transition: background-color .2s; }
.folder-tabs .folder-tab[aria-current="page"] { height: 69px; min-height: 69px; }
.folder-tabs .folder-tab::after { content: none; display: none; }
.folder-tab .tab-label, .folder-tab .tab-short { margin-right: 0; }
.folder-tab .tab-short { display: none; }
@media(max-width:700px) {
  .folder-tabs { grid-template-columns: repeat(4,minmax(0,1fr)); min-height: 64px; padding: 0; background: transparent; border-radius: 0; }
  .folder-tabs::after { content: none; }
  .archive:not(.reading-archive) > .folder-body { border-top-left-radius: 0; border-top-right-radius: 0; }
  .folder-tabs .folder-tab:nth-child(n) { height: 54px; min-height: 54px; padding: 8px 5px 9px; font-size: 11px; line-height: 1.2; border-radius: 10px 16px 0 0; white-space: normal; text-align: center; }
  .folder-tabs .folder-tab[aria-current="page"] { height: 64px; min-height: 64px; padding-top: 13px; text-decoration: none; }
  .folder-tab .tab-number { display: block; margin: 0 0 5px; font-size: 9px; opacity: .7; }
  .folder-tab .tab-label { display: none; }
  .folder-tab .tab-short { display: block; }
}
