/* thealtimist.com — page styles.
 *
 * Colour, type and layout come from the-altimist.css (The Altimist Style Guide,
 * May 2024), which layers over altimist.css (Altimist Design System) for the
 * elevation ladder and the dark theme. No raw hex values live here.
 *
 * The layout is the guide's own document structure: a Dark Blue rail carrying
 * the lockup and section nav, against a Pale Beige canvas.
 */

/* ---------------------------------------------------------------- reset */

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  /* Match the canvas so there is no seam below the last section. */
  background: var(--ta-canvas);
  color: var(--al-text-primary);
  font-family: var(--al-font-body);
  font-size: var(--ta-body);
  line-height: var(--ta-prose-lh);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--al-focus-ring);
  outline-offset: 3px;
  border-radius: var(--al-radius-sm);
}

/* --------------------------------------------------------- type primitives */

/* Guide p.15: headings are Brandon Text, uppercase, on the 36/24/20/18/16/14
   scale with the matching line heights. */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--al-font-heading);
  font-weight: 500;
  text-transform: var(--ta-heading-case);
  letter-spacing: var(--ta-heading-track);
  color: var(--al-text-primary);
}

h1 { font-size: var(--ta-h1); line-height: var(--ta-h1-lh); }
h2 { font-size: var(--ta-h2); line-height: var(--ta-h2-lh); }
h3 { font-size: var(--ta-h3); line-height: var(--ta-h3-lh); }
h4 { font-size: var(--ta-h4); line-height: var(--ta-h4-lh); }
h5 { font-size: var(--ta-h5); line-height: var(--ta-h5-lh); }
h6 { font-size: var(--ta-h6); line-height: var(--ta-h6-lh); }

.eyebrow {
  margin: 0 0 0.75rem;
  font-family: var(--al-font-ui);
  font-weight: 500;
  font-size: var(--ta-h6);
  line-height: var(--ta-h6-lh);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--meta);
}

.mono {
  font-family: var(--al-font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  font-variant-ligatures: none;
}

/* The Dark Sand rule — the one decorative device, used as a section marker. */
.rule {
  width: 3.5rem;
  height: 2px;
  margin: 1.25rem 0 0;
  border: 0;
  background: var(--ta-rule);
}

.hairline {
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--al-border-default);
}

/* -------------------------------------------------------------- the shell */

.shell { min-height: 100vh; }

/* Guide p.14: 8 columns, 30px gutters, 15px at the grid edges. The content
   column spans 6 of the 8 so the measure stays readable. */
.wrap {
  display: grid;
  grid-template-columns: repeat(var(--ta-cols), minmax(0, 1fr));
  column-gap: var(--ta-gutter);
  padding-inline: clamp(var(--ta-edge), 5vw, 3.5rem);
}

.wrap > * { grid-column: 1 / -1; }

@media (min-width: 60rem) {
  .wrap > .col { grid-column: 1 / span 6; }
}

/* ----------------------------------------------------------------- rail */

.rail {
  background: var(--ta-dark-blue);
  color: var(--ta-pale-beige);
  padding: 1.5rem clamp(var(--ta-edge), 5vw, 2rem);
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.rail-brand { display: block; margin-right: auto; }

/* Guide p.7: horizontal lockup never below 16px tall. This renders at 22px. */
.rail-brand svg {
  width: auto;
  height: 1.375rem;
  color: var(--ta-light-sand);
}

.rail-nav { display: flex; gap: 1.5rem; }

.rail-nav a {
  font-family: var(--al-font-ui);
  font-weight: 500;
  font-size: var(--ta-h6);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ta-light-sand);
  padding-block: 0.375rem;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.rail-nav a:hover {
  color: var(--ta-pale-beige);
  border-bottom-color: var(--ta-dark-sand);
}

@media (max-width: 44rem) { .rail-nav { display: none; } }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.125rem;
  height: 2.125rem;
  padding: 0;
  border: 1px solid var(--ta-dark-sand);
  border-radius: var(--al-radius-full);
  background: transparent;
  color: var(--ta-light-sand);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover { background: var(--ta-dark-sand); color: var(--ta-dark-blue); }
.theme-toggle svg { width: 1rem; height: 1rem; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* Desktop: the rail becomes the guide's fixed left column. */
@media (min-width: 64rem) {
  .shell {
    display: grid;
    grid-template-columns: 16.5rem minmax(0, 1fr);
  }

  .rail {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    flex-direction: column;
    align-items: flex-start;
    gap: 2.5rem;
    padding: 3rem 2.25rem;
  }

  .rail-brand { margin: 0; }
  .rail-brand svg { height: auto; width: 9.5rem; }
  .rail-nav { flex-direction: column; gap: 0.625rem; margin-right: auto; }
  .rail-foot { margin-top: auto; display: grid; gap: 1.25rem; }
  .rail-note { margin: 0; color: var(--ta-light-sand); }
}

.rail-foot { display: contents; }
.rail-note { display: none; }

@media (min-width: 64rem) {
  .rail-foot { display: grid; }
  .rail-note { display: block; }
}

/* --------------------------------------------------------------- canvas */

.canvas { background: var(--ta-canvas); min-width: 0; }

.section { padding-block: clamp(3rem, 7vw, 5rem); }

.section-head { margin-bottom: 2rem; }
.section-head .rule { margin-top: 1rem; }

.prose { max-width: 34rem; }
.prose p { margin: 0 0 1.125rem; }
.prose p:last-child { margin-bottom: 0; }
.prose a {
  color: var(--al-text-primary);
  text-decoration-line: underline;
  text-decoration-color: var(--ta-dark-sand);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.15s ease;
}
.prose a:hover { text-decoration-color: var(--al-text-primary); }

/* ------------------------------------------------------------------ hero */

.hero { padding-block: clamp(3.5rem, 9vw, 6.5rem) clamp(2.5rem, 6vw, 4rem); }

.hero h1 { color: var(--al-text-primary); }

.lede {
  max-width: 30rem;
  margin: 1.75rem 0 0;
  font-size: var(--ta-h2);
  line-height: var(--ta-h2-lh);
  color: var(--al-text-secondary);
}

.standfirst {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 2rem 0 0;
  color: var(--meta);
  text-transform: uppercase;
  line-height: var(--ta-body-lh);
}

.standfirst span + span::before {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1px;
  margin-right: 1rem;
  vertical-align: middle;
  background: var(--ta-rule);
}

/* ----------------------------------------------------------------- paper */

.paper {
  display: grid;
  gap: 1.25rem;
  max-width: 44rem;
  padding: clamp(1.25rem, 3.5vw, 2rem);
  background: var(--al-bg-elevated);
  border: 1px solid var(--al-border-muted);
  border-radius: var(--al-radius-md);
  box-shadow: var(--al-shadow-sm);
}

.paper-head { display: grid; gap: 0.625rem; }

.paper h3 { color: var(--al-text-primary); }

.paper-sub {
  margin: 0;
  font-style: italic;
  font-size: var(--ta-h4);
  line-height: var(--ta-h4-lh);
  color: var(--al-text-secondary);
  text-transform: none;
}

.paper-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.625rem;
  margin: 0;
  color: var(--meta);
  text-transform: uppercase;
  line-height: var(--ta-body-lh);
}

.paper-meta span + span::before { content: "· "; }

.abstract { margin: 0; color: var(--al-text-secondary); }
.abstract b {
  display: block;
  margin-bottom: 0.375rem;
  font-family: var(--al-font-ui);
  font-weight: 500;
  font-size: var(--ta-h6);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--meta);
}

.claim {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--al-bg-subtle);
  border-left: 2px solid var(--ta-rule);
}

.claim code {
  font-family: var(--al-font-mono);
  font-size: 0.8125rem;
  color: var(--al-text-primary);
  white-space: nowrap;
}

.claim small {
  font-family: var(--al-font-ui);
  font-size: var(--ta-h6);
  line-height: var(--ta-h6-lh);
  color: var(--meta);
}

@media (max-width: 40rem) {
  .claim { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  /* The formula is nowrap by design; contain it rather than let a wider
     fallback mono face push the document. */
  .claim code { max-width: 100%; min-width: 0; overflow-x: auto; }
}

.paper-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  font-family: var(--al-font-ui);
  font-weight: 500;
  font-size: var(--ta-h6);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--al-radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn svg { width: 0.875rem; height: 0.875rem; }

.btn-primary { background: var(--ta-accent); color: var(--al-accent-text); }
.btn-primary:hover { background: var(--ta-dark-sand); color: var(--ta-dark-blue); }

.btn-quiet {
  background: transparent;
  color: var(--al-text-primary);
  border-color: var(--ta-dark-sand);
}
.btn-quiet:hover { background: var(--al-bg-hover); }

.cite { margin: 0; }

.cite summary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  list-style: none;
  font-family: var(--al-font-ui);
  font-size: var(--ta-h6);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--meta);
}
.cite summary::-webkit-details-marker { display: none; }
.cite summary:hover { color: var(--al-text-primary); }
.cite summary::after { content: "+"; font-size: var(--ta-h5); line-height: 1; }
.cite[open] summary::after { content: "\2013"; }

.cite p {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.875rem;
  background: var(--al-bg-subtle);
  font-family: var(--al-font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--al-text-secondary);
}

.aside {
  max-width: 34rem;
  margin: 1.5rem 0 0;
  padding-left: 1rem;
  border-left: 1px solid var(--ta-rule);
  color: var(--meta);
}

/* -------------------------------------------------------------- elsewhere */

.links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--ta-edge);
  max-width: 44rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.links a {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  background: var(--al-bg-surface);
  border: 1px solid var(--al-border-muted);
  border-radius: var(--al-radius-sm);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.links a:hover {
  border-color: var(--ta-dark-sand);
  background: var(--al-bg-elevated);
}

.links svg { flex: none; width: 1.0625rem; height: 1.0625rem; color: var(--ta-dark-sand); }
.links a:hover svg { color: var(--al-text-primary); }

.links .label { display: grid; gap: 0.125rem; min-width: 0; }

.links .label b {
  font-family: var(--al-font-ui);
  font-weight: 500;
  font-size: var(--ta-h6);
  line-height: var(--ta-h6-lh);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--al-text-primary);
}

.links .label small {
  min-width: 0;
  font-family: var(--al-font-mono);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--meta);
  overflow-wrap: anywhere;
}

.contact { margin: 1.5rem 0 0; color: var(--al-text-secondary); }

/* ----------------------------------------------------------------- footer */

.site-footer { padding-block: 2rem 2.5rem; color: var(--meta); }

.site-footer .wrap { row-gap: 0.5rem; }

.site-footer .foot-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--al-border-default);
  text-transform: uppercase;
}

.site-footer a {
  text-decoration-line: underline;
  text-decoration-color: var(--ta-dark-sand);
  text-underline-offset: 0.2em;
}
.site-footer a:hover { color: var(--al-text-primary); }

/* ------------------------------------------------------------------- 404 */

.notfound {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 1.25rem;
  min-height: 70vh;
}
