/* ==========================================================================
   medical-practice.com
   World: end-tab chart filing. Shelved surfaces are the records room read
   edge-on; opened surfaces are the chart on the desk. Color is wayfinding,
   never decoration. Rank is band width, not type size.
   One face throughout: Archivo variable (width + weight axes).
   ========================================================================== */

/* ---------- Tokens ---------- */

:root {
  /* Records room. Warm near-black, not blue-black: these are paper shelves. */
  --shelf-900: #100E0B;
  --shelf-800: #1A1713;
  --shelf-700: #272219;
  --shelf-line: #3A3227;
  --shelf-text: #EDE9E1;
  --shelf-dim: #A79C8A;

  /* Chart on the desk. Cool-neutral stock, deliberately not cream. */
  --paper: #F7F7F5;
  --paper-sunk: #EDEDEA;
  --paper-line: #D8D8D3;
  --ink: #16161A;
  --ink-soft: #4A4A52;

  /* End-tab alphabetic colors. Real filing colors, contrast-checked
     against white at 4.5:1 or better so labels can sit inside the band. */
  --tab-revenue:    #C6202B;
  --tab-people:     #1B7F4B;
  --tab-operations: #A55408;
  --tab-compliance: #14539E;
  --tab-technology: #6A3B96;
  --tab-strategy:   #0E7C7B;

  --tab: var(--tab-revenue); /* per-section override */

  --measure: 68ch;
  --step: clamp(1rem, 0.6rem + 1.4vw, 1.6rem);
  --rule: 1px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Reset-ish ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Archivo", system-ui, sans-serif;
  font-variation-settings: "wdth" 100, "wght" 400;
  background: var(--paper);
  color: var(--ink);
  font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  line-height: 1.62;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

/* ---------- Browser surfaces: these ship with the design ---------- */

::selection { background: var(--tab); color: #fff; }

:focus-visible {
  outline: 3px solid var(--tab);
  outline-offset: 3px;
  border-radius: 1px;
}

html { scrollbar-color: var(--shelf-line) var(--paper-sunk); scrollbar-width: thin; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--paper-sunk); }
::-webkit-scrollbar-thumb { background: var(--shelf-line); border: 3px solid var(--paper-sunk); }
::-webkit-scrollbar-thumb:hover { background: var(--shelf-700); }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }

/* Tabular data and dates align on the numeral */
time, .num { font-variant-numeric: tabular-nums; }

/* ---------- Type ---------- */

h1, h2, h3, .label {
  font-variation-settings: "wdth" 78, "wght" 700;
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: clamp(2.4rem, 1.4rem + 4.4vw, 5.2rem); }
h2 { font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.6rem); }
h3 { font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.6rem); }

/* The label is the typed tab. Caps, condensed, tracked out. */
.label {
  font-variation-settings: "wdth" 70, "wght" 700;
  font-size: 0.72rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  line-height: 1;
}

p { margin: 0 0 1.1em; max-width: var(--measure); }

/* ---------- Layout ---------- */

.wrap { width: min(100% - 2.5rem, 76rem); margin-inline: auto; }
.wrap-read { width: min(100% - 2.5rem, 42rem); margin-inline: auto; }

.skip {
  position: absolute; left: -9999px;
  background: var(--tab); color: #fff; padding: 0.75rem 1.25rem;
  font-variation-settings: "wdth" 70, "wght" 700;
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem;
}
.skip:focus { left: 1rem; top: 1rem; z-index: 100; }

/* ==========================================================================
   SHELF SURFACES (closed charts, read edge-on)
   ========================================================================== */

.shelf {
  background: var(--shelf-900);
  color: var(--shelf-text);
  /* Faint vertical striation: folder edges packed on a shelf. */
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255,255,255,0.028) 0 1px,
    transparent 1px 7px
  );
}

/* ---------- Masthead ---------- */

.masthead { padding: clamp(1.1rem, 2vw, 1.6rem) 0; border-bottom: var(--rule) solid var(--shelf-line); }
.masthead-in { display: flex; align-items: baseline; gap: 1.5rem; flex-wrap: wrap; }

.wordmark {
  font-variation-settings: "wdth" 70, "wght" 800;
  font-size: 1.02rem; letter-spacing: 0.1em; text-transform: uppercase;
  text-decoration: none; color: var(--shelf-text); white-space: nowrap;
}
.wordmark span { color: var(--shelf-dim); }

.nav { margin-left: auto; }
.nav ul { display: flex; gap: clamp(1rem, 2.4vw, 2.1rem); list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.nav a {
  font-variation-settings: "wdth" 74, "wght" 600;
  font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--shelf-dim); text-decoration: none;
  padding-block: 0.35rem; border-bottom: 2px solid transparent;
  transition: color 0.18s var(--ease-out), border-color 0.18s var(--ease-out);
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--shelf-text); border-bottom-color: var(--tab); }

/* ---------- Hero ---------- */

.hero { padding: clamp(3.5rem, 9vw, 8rem) 0 clamp(2.5rem, 5vw, 4rem); }
.hero h1 { max-width: 18ch; }
.hero .lede {
  margin-top: 1.6rem; max-width: 46ch;
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.45rem);
  line-height: 1.5; color: var(--shelf-dim);
}

.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(2.5rem, 5vw, 4rem); align-items: center; }

/* ---------- The rack ----------
   The index, shown as what it is: six charts standing in a drawer, tabs
   stepping down into the staircase an end-tab system makes. It teaches the
   colour code before the reader scrolls into it. Assembles once on load and
   then holds; it is not a loop, because a hero that keeps moving while you
   read is a cost, not a feature. */

.rack {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(4px, 0.6vw, 8px);
  height: clamp(240px, 30vw, 340px);
  padding: 1rem 1rem 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.35) 0%, transparent 22%),
    var(--shelf-800);
  border: 1px solid var(--shelf-line);
}

.spine {
  position: relative;
  height: 100%;
  background: linear-gradient(90deg, #241F19 0%, #2E2820 38%, #221D17 100%);
  overflow: hidden;
  transition: transform 0.34s var(--ease-out);
}

/* The tab: same staircase grammar as the real index below. */
.spine-tab {
  position: absolute; left: 0; right: 0;
  top: calc(6% + var(--i) * 11%);
  height: 15%;
  background: var(--c);
  box-shadow: 0 2px 5px rgba(0,0,0,0.45);
}

.spine-txt {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  top: calc(6% + var(--i) * 11% + 17%);
  writing-mode: vertical-rl;
  font-variation-settings: "wdth" 68, "wght" 600;
  font-size: clamp(0.58rem, 0.5rem + 0.24vw, 0.72rem);
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--shelf-dim);
  white-space: nowrap;
}

.rack:hover .spine { transform: translateY(6px); }
.rack .spine:hover { transform: translateY(-10px); }
.rack .spine:hover .spine-txt { color: var(--shelf-text); }

/* ==========================================================================
   THE SHELF: staggered end-tab index.
   Position across the row encodes the subject, the way an alphabetic
   end-tab system does. Color is doubled by position AND label so it never
   carries meaning alone.
   ========================================================================== */

.stack { list-style: none; margin: 0; padding: 0 0 clamp(3rem, 7vw, 6rem); }

.folder {
  --pos: 0;
  border-top: var(--rule) solid var(--shelf-line);
}
.folder:last-child { border-bottom: var(--rule) solid var(--shelf-line); }

.folder a {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem 2rem;
  padding: clamp(1.4rem, 2.6vw, 2.1rem) 0;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: background-color 0.22s var(--ease-out);
}

/* The tab: a saturated band whose horizontal offset steps with --pos. */
.folder .tab {
  position: absolute;
  top: 0;
  left: calc(var(--pos) * 5.5rem);
  width: 4.4rem;
  height: 100%;
  background: var(--tab);
  transition: width 0.28s var(--ease-out), left 0.28s var(--ease-out);
}

.folder .body { position: relative; padding-left: calc(var(--pos) * 5.5rem + 6.2rem); }

.folder h2 { transition: color 0.2s var(--ease-out); }
.folder p { color: var(--shelf-dim); margin: 0.55rem 0 0; max-width: 52ch; }

.folder .file-no {
  font-variation-settings: "wdth" 70, "wght" 700;
  font-size: 0.72rem; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--shelf-dim); display: block; margin-bottom: 0.5rem;
}

.folder a:hover { background: var(--shelf-800); }
.folder a:hover .tab { width: 5.6rem; }
.folder a:hover h2 { color: var(--tab); }
.folder a:focus-visible { outline-offset: -4px; }

/* Per-folder color assignment */
.f-revenue    { --tab: var(--tab-revenue); }
.f-people     { --tab: var(--tab-people); }
.f-operations { --tab: var(--tab-operations); }
.f-compliance { --tab: var(--tab-compliance); }
.f-technology { --tab: var(--tab-technology); }
.f-strategy   { --tab: var(--tab-strategy); }

/* ==========================================================================
   PAPER SURFACES (chart pulled and opened)
   ========================================================================== */

.sheet { background: var(--paper); color: var(--ink); padding: clamp(3rem, 7vw, 5.5rem) 0; }

/* The spine: tab color persists down the left edge of an opened chart. */
.sheet-titled { border-top: 6px solid var(--tab); }

.sheet h2 { margin-bottom: 1.1rem; }
.sheet h3 { margin: 2.4rem 0 0.7rem; }

.sheet .label { color: var(--tab); margin-bottom: 0.9rem; display: block; }

hr.rule { border: 0; border-top: var(--rule) solid var(--paper-line); margin: 0; }

/* ---------- Long-form article ---------- */

.article { padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(3rem, 7vw, 5rem); }
.article h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.4rem); max-width: 22ch; }
.article-meta {
  font-variation-settings: "wdth" 74, "wght" 600;
  font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0 0 1.4rem;
}
.article-body { margin-top: 2.2rem; }
.article-body h2 { font-size: clamp(1.4rem, 1.2rem + 0.9vw, 1.9rem); margin: 2.8rem 0 0.8rem; }
.article-body p { color: var(--ink); }
.article-body a { color: var(--tab); text-decoration-color: color-mix(in srgb, var(--tab) 45%, transparent); }
.article-body a:hover { text-decoration-color: var(--tab); }

.author-note {
  margin-top: 3rem; padding-top: 1.5rem;
  border-top: var(--rule) solid var(--paper-line);
  font-size: 0.95rem; color: var(--ink-soft);
}
.author-note p strong { color: var(--ink); }

/* Author byline photo. The tab colour carries onto the plate edge, the same
   way the about-page portraits are filed. Stacks under 30rem. */
.author-note:has(.author-photo) {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 1.2rem;
  align-items: start;
}
.author-photo {
  display: block; width: 100%; height: auto;
  border-top: 4px solid var(--tab);
}
@media (max-width: 30rem) {
  .author-note:has(.author-photo) { grid-template-columns: minmax(0, 1fr); }
  .author-photo { max-width: 5.5rem; }
}

/* Opening paragraph of a drawer page: the summary a scanner reads first. */
.entry-lede {
  font-size: clamp(1.15rem, 1.05rem + 0.55vw, 1.45rem);
  line-height: 1.48;
  color: var(--ink);
  max-width: 40ch;
  margin-bottom: 2rem;
}

.plain-list { list-style: none; margin: 0.7rem 0 0; padding: 0; display: grid; gap: 0.45rem; }
.plain-list a { color: var(--tab); }

/* About page: a second and third portrait, at chart-plate scale. */
.plates { display: grid; grid-template-columns: minmax(0,1fr); gap: clamp(1.4rem, 3vw, 2.4rem); margin-top: 2.6rem; }
.plate { margin: 0; border-top: 6px solid var(--tab); }
.plate img { width: 100%; }
.plate figcaption { font-size: 0.82rem; color: var(--ink-soft); padding-top: 0.55rem; }

@media (min-width: 46rem) { .plates { grid-template-columns: 1fr 1fr; } }

/* The lead portrait, filed above the essay rather than beside it. Wider band
   than the pair below, because it is the one that identifies the writer. */
.plate-lead { max-width: 26rem; margin: 2.2rem 0 0; border-top-width: 10px; }

/* ---------- Filed articles ----------
   Deliberately above the overview essay on a drawer page. A returning reader
   wants what is new; the overview is what they already read once. */

.filed {
  margin: 2.4rem 0 3rem;
  border-top: 3px solid var(--tab);
}

.filed-head {
  font-variation-settings: "wdth" 70, "wght" 700;
  font-size: 0.74rem; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink); margin: 0.9rem 0 0.2rem;
  display: flex; align-items: center; gap: 0.7rem;
}
.filed-count {
  background: var(--tab); color: #fff;
  font-variant-numeric: tabular-nums;
  padding: 0.12em 0.5em; border-radius: 1px; letter-spacing: 0.04em;
}
.filed-empty { font-size: 0.95rem; color: var(--ink-soft); margin: 0.7rem 0 0; }

.overview-head { margin-top: 0; }

/* Breadcrumb back to the drawer an article is filed in */
.crumbs {
  font-variation-settings: "wdth" 74, "wght" 600;
  font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 1rem;
}
.crumbs a { color: var(--tab); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span { padding: 0 0.4rem; color: var(--paper-line); }

/* Latest-article line on the index rows */
.folder-recent {
  display: inline-block; margin-top: 0.7rem;
  font-variation-settings: "wdth" 76, "wght" 600;
  font-size: 0.82rem; color: var(--shelf-text);
  border-bottom: 1px solid var(--tab); padding-bottom: 2px;
}

/* ---------- Post list ---------- */

.posts { list-style: none; margin: 0; padding: 0; }
.posts li { border-top: var(--rule) solid var(--paper-line); }
.posts li:last-child { border-bottom: var(--rule) solid var(--paper-line); }
.posts a { display: block; padding: 1.7rem 0 1.7rem 1.4rem; text-decoration: none; position: relative; }
.posts a::before {
  content: ""; position: absolute; left: 0; top: 1.7rem; bottom: 1.7rem;
  width: 4px; background: var(--tab);
}
.posts a:hover h3 { color: var(--tab); }
.posts .article-meta { margin-bottom: 0.5rem; }
.posts p { margin: 0.4rem 0 0; color: var(--ink-soft); max-width: 60ch; }

/* ---------- Portrait ---------- */

.portrait-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(1.8rem, 4vw, 3.2rem); align-items: start; }
.portrait { border-top: 6px solid var(--tab); }
.portrait img { width: 100%; }
.portrait figcaption { font-size: 0.82rem; color: var(--ink-soft); padding-top: 0.6rem; }

/* ---------- Disclaimer ----------
   Deliberately not a tiny grey legal footnote. It is a section with its own
   heading, because a disclaimer nobody reads protects nobody. */

.disclaimer-band { background: var(--paper-sunk); border-top: 3px solid var(--ink); padding-block: clamp(2.2rem, 4vw, 3.2rem); }
.disclaimer-head { font-size: clamp(1.2rem, 1.1rem + 0.5vw, 1.5rem); margin-bottom: 1rem; }
.disclaimer-band p { font-size: 0.95rem; color: var(--ink-soft); }
.disclaimer-band strong { color: var(--ink); font-variation-settings: "wdth" 100, "wght" 700; }

.foot-legal {
  margin-top: 2.4rem; padding-top: 1.4rem;
  border-top: var(--rule) solid var(--shelf-line);
  font-size: 0.8rem; line-height: 1.55; color: var(--shelf-dim); max-width: 78ch;
}
.foot-legal + .foot-base { margin-top: 1.2rem; border-top: 0; padding-top: 0; }

/* ---------- Footer ---------- */

.foot { background: var(--shelf-900); color: var(--shelf-dim); padding: clamp(2.5rem, 5vw, 4rem) 0 2rem; }
.foot-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 1.8rem; }
.foot a { color: var(--shelf-text); }
.foot .label { color: var(--shelf-dim); margin-bottom: 0.8rem; }
.foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.foot-base {
  margin-top: 2.4rem; padding-top: 1.4rem;
  border-top: var(--rule) solid var(--shelf-line);
  font-size: 0.82rem; display: flex; gap: 1.4rem; flex-wrap: wrap;
}

/* ---------- Responsive ---------- */

@media (min-width: 46rem) {
  .portrait-row { grid-template-columns: 1fr 28rem; }
  .foot-grid { grid-template-columns: 2fr 1fr 1fr; }
}

@media (min-width: 62rem) {
  .hero-grid { grid-template-columns: 1.15fr 0.85fr; }
}

/* Narrow: vertical spine labels stop being legible long before the rack
   stops being useful, so the labels go and the colour bands stay. */
@media (max-width: 44rem) {
  .rack { height: clamp(150px, 34vw, 200px); }
  .spine-txt { display: none; }
}

/* Narrow: the stagger costs too much width, so the tab returns to the
   left edge and position is carried by the file number alone. */
@media (max-width: 52rem) {
  .folder .tab { left: 0; width: 3.2rem; }
  .folder a:hover .tab { width: 3.9rem; }
  .folder .body { padding-left: 4.6rem; }
}

@media (max-width: 34rem) {
  .folder .tab { width: 0.55rem; }
  .folder a:hover .tab { width: 0.55rem; }
  .folder .body { padding-left: 1.5rem; }
}

/* ---------- Motion: one authored moment ---------- */
/* Folders settle into the shelf on load, stepping in reading order.
   Default state is visible; the animation only offsets it. */

/* One orchestrated moment, not two effects: the charts drop into the rack in
   reading order, and the index below begins settling partway through that
   cascade so the two overlap into a single continuous "the shelf loads"
   rather than two phases with a dead pause between them. Same easing, same
   rhythm. Everything is at rest by ~1.6s and nothing loops: a hero that keeps
   moving while you read is a cost, not a feature. */

@media (prefers-reduced-motion: no-preference) {
  .spine {
    animation: file-in 0.66s var(--ease-out) both;
    animation-delay: calc(var(--i) * 80ms);
  }
  @keyframes file-in {
    from { transform: translateY(-112%); }
    to   { transform: translateY(0); }
  }

  .spine-txt {
    animation: label-in 0.5s var(--ease-out) both;
    animation-delay: calc(var(--i) * 80ms + 380ms);
  }
  @keyframes label-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  .folder {
    animation: settle 0.62s var(--ease-out) both;
    animation-delay: calc(560ms + var(--pos) * 55ms);
  }
  @keyframes settle {
    from { opacity: 0; transform: translateY(0.7rem); }
    to   { opacity: 1; transform: none; }
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .shelf, .foot { background: #fff; color: #000; }
  .nav, .skip { display: none; }
}
