/* ============================================================
   KEVIN VALMORBIDA — SEPIA TYPOGRAPHIC DESIGN SYSTEM
   style.css · single shared stylesheet for all pages
   ============================================================ */

/* ============================================================
   1 · DESIGN TOKENS
   ============================================================ */
:root {
  color-scheme: light dark;

  /* Palette — sepia ink-on-paper */
  --color-paper: #fdf8f0;
  --color-parchment: #ede5d0;
  --color-inset: #f2ead8;
  --color-rule: #c8b99a;
  --color-rule-strong: #9e8668;
  --color-ink: #231608;
  --color-ink-muted: #7a6245;
  --color-ink-faint: #b39876;
  --color-accent: #8b5e3c;
  --color-accent-dark: #5c3a1e;
  --color-visited: #6b4e31;
  --color-highlight: #f3e9c6;

  /* Convenience aliases — used throughout all components */
  --bg: var(--color-paper);
  --bg-nav: var(--color-parchment);
  --bg-inset: var(--color-inset);
  --border: var(--color-rule);
  --text: var(--color-ink);
  --text-muted: var(--color-ink-muted);
  --accent: var(--color-accent);
  --accent-h: var(--color-accent-dark);
  --visited: var(--color-visited);

  /* Typefaces — system fonts, no external CDN */
  --font-serif: Georgia, "Palatino Linotype", Palatino, "Book Antiqua", serif;
  --font-sans: Optima, Candara, Calibri, "Gill Sans", system-ui, sans-serif;
  --font-mono: "Courier New", Courier, monospace;

  /* Type scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1.0625rem;
  --text-lg: 1.1875rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.625rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3.25rem;

  /* Line heights */
  --leading-tight: 1.2;
  --leading-snug: 1.4;
  --leading-normal: 1.65;
  --leading-relaxed: 1.8;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Layout */
  --container-width: 42rem;
  --masthead-height: 3.5rem;

  /* Border radii */
  --radius-sm: 0.15rem;
  --radius: 0.3rem;
  --radius-lg: 0.5rem;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(35, 22, 8, 0.07);
  --shadow: 0 4px 16px rgba(35, 22, 8, 0.09);
  --shadow-lg: 0 8px 32px rgba(35, 22, 8, 0.14);
}

/* ============================================================
   2 · RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* keeps focused and anchored elements clear of the pinned nav row (~67px) */
  scroll-padding-top: calc(var(--space-16) + var(--space-4));
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  /* column layout: on short pages the footer sits at the bottom of the window */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  background: var(--bg);
  color: var(--text);
}

/* ============================================================
   3 · TYPOGRAPHY
   ============================================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--color-ink);
  margin: var(--space-8) 0 var(--space-4);
}

h1 {
  font-size: var(--text-4xl);
  letter-spacing: -0.02em;
  margin-top: var(--space-6);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--border);
}

h2 {
  font-size: var(--text-2xl);
  letter-spacing: -0.01em;
  margin-top: var(--space-10);
}

h2::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 2px;
  background: var(--accent);
  margin-top: var(--space-2);
}

h3 {
  font-size: var(--text-xl);
  margin-top: var(--space-6);
}

h4 {
  font-size: var(--text-lg);
  font-style: italic;
  font-weight: 400;
}

p {
  margin: 0 0 var(--space-5);
}

small {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
}

code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
  color: var(--color-accent-dark);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--space-4);
  overflow-x: auto;
  line-height: var(--leading-normal);
  margin: 0 0 var(--space-5);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

blockquote {
  margin: var(--space-8) 0;
  padding: var(--space-4) var(--space-6);
  border-left: 4px solid var(--accent);
  background: var(--bg-inset);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--color-ink-muted);
}

blockquote cite {
  display: block;
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  font-style: normal;
  font-family: var(--font-sans);
  color: var(--text-muted);
}

ul,
ol {
  padding-left: var(--space-6);
  margin: 0 0 var(--space-5);
}

li {
  margin-bottom: var(--space-2);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--space-5);
  font-size: var(--text-sm);
}

th {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  border-bottom: 2px solid var(--border);
  padding: var(--space-2) var(--space-3);
  color: var(--text-muted);
}

td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

/* wrapper for tables that may be wider than a phone screen */
.table-scroll {
  overflow-x: auto;
  margin: 0 0 var(--space-5);
}

.table-scroll > table {
  margin: 0;
}

/* the wrapper scrolls, so token names can stay on one line */
.table-scroll code {
  white-space: nowrap;
}

/* ============================================================
   4 · LINKS
   ============================================================ */
a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 0.15s;
}
/* :visited must precede :hover, otherwise visited links lose their hover state */
a:visited {
  color: var(--visited);
}
a:hover {
  color: var(--accent-h);
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   5 · DIVIDER
   ============================================================ */
hr {
  border: none;
  margin: var(--space-10) 0;
  text-align: center;
  color: var(--color-ink-faint);
  font-size: var(--text-lg);
  line-height: 1;
}

hr::before {
  content: "\2014\a0\2726\a0\2014";
  letter-spacing: 0.2em;
  display: block;
  font-family: var(--font-serif);
}

/* ============================================================
   6 · HEADER
   Masthead (the site name) above the nav row. The header sticks
   with a negative offset: the masthead scrolls away and only the
   nav row stays pinned.
   ============================================================ */
header {
  position: sticky;
  top: calc(-1 * var(--masthead-height));
  z-index: 50;
  background: var(--bg-nav);
  border-bottom: 3px double var(--border);
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--masthead-height);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
}

/* one line only (the row has a fixed height): with very large text it ends in an ellipsis */
.masthead-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
}

a.masthead-title:visited {
  color: var(--text);
}

a.masthead-title:hover {
  color: var(--accent-h);
}

header nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  margin: 0;
}

header nav a,
.ds-nav-replica > span {
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition:
    border-color 0.15s,
    background 0.15s;
}

header nav a:visited {
  color: var(--text);
}

header nav a:hover,
header nav a[aria-current="page"],
.ds-nav-replica .is-active {
  border-color: var(--border);
  background: color-mix(in srgb, var(--border) 25%, transparent);
  color: var(--text);
}

/* ============================================================
   7 · LAYOUT
   ============================================================ */
/* main is the flexible row of the body column: it pushes the footer down */
main {
  flex: 1 0 auto;
}

/* about 75 characters per line for body text */
.container {
  width: 100%;
  max-width: var(--container-width);
  margin: var(--space-8) auto 0;
  padding: 0 var(--space-4);
}

.not-found {
  text-align: center;
  padding-top: var(--space-16);
}

/* ============================================================
   8 · IMAGES
   ============================================================ */
img {
  border-radius: var(--radius);
}

/* ============================================================
   9 · FOOTER
   ============================================================ */
footer {
  border-top: 3px double var(--border);
  padding: var(--space-5) 0;
  margin-top: var(--space-12);
  background: var(--bg-nav);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  /* same box as .container, so the footer text lines up with the content */
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* the credits wrap on their own line breaks, keeping the icons beside them */
.footer-credits {
  flex: 1 1 12rem;
}

/* text links in the credits stay muted: the accent is below 4.5:1 on parchment */
.footer-credits a,
.footer-credits a:visited {
  color: inherit;
}

.footer-credits a:hover {
  color: var(--text);
}

.footer-links {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

.footer-links a {
  text-decoration: none;
  font-size: 1.25rem;
  opacity: 0.8;
  color: inherit;
  transition: opacity 0.15s;
}

.footer-links a:visited {
  color: inherit;
}
.footer-links a:hover {
  opacity: 1;
  color: inherit;
}

/* ============================================================
   10 · TAGS
   ============================================================ */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.tag {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  line-height: var(--leading-snug);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-inset);
}

/* ============================================================
   11 · POST LIST & CARDS
   ============================================================ */
.post-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

@media (min-width: 36rem) {
  .post-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* The card is an <article> and only its title is a link, so screen readers
   announce just the title; the link's ::after covers the whole card to keep
   all of it clickable. */
.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-inset);
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow 0.15s,
    transform 0.15s;
}

.post-card:hover,
.post-card:focus-within {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.post-card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-nav);
}

.post-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  display: block;
  transition: transform 0.3s;
}

.post-card:hover .post-card-thumb img {
  transform: scale(1.02);
}

.post-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
}

.post-card-body p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--text-muted);
  flex: 1;
}

.post-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-1);
}

.post-card-header small {
  white-space: nowrap;
}

/* The card title is an <h2> for heading navigation, styled as card text */
.post-card-title {
  margin: 0;
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  letter-spacing: normal;
}

.post-card-title::after {
  display: none;
}

.post-card-title a,
.post-card-title a:visited {
  color: inherit;
  text-decoration: none;
}

.post-card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

/* the focus ring goes around the whole card, inset because the card clips overflow */
.post-card-title a:focus-visible {
  outline: none;
}

.post-card-title a:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--radius-lg);
}

/* Post index: compact list of posts (home "Latest posts") */
.post-index {
  list-style: none;
  padding: 0;
}

.post-index li {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

/* dotted leader between title and date, like a table of contents */
.post-index li::after {
  content: "";
  order: 1;
  flex: 1;
  min-width: var(--space-4);
  border-bottom: 1px dotted var(--color-rule-strong);
}

.post-index time {
  order: 2;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============================================================
   12 · ARTICLE PROSE
   ============================================================ */
.hero-image-wrap {
  position: relative;
  width: 100%;
  max-height: 22rem;
  overflow: hidden;
  margin-bottom: var(--space-6);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

/* the hero is a <picture>: AVIF with a JPEG fallback */
.hero-image-wrap picture {
  display: block;
}

.hero-image-wrap img {
  width: 100%;
  height: auto;
  max-height: 22rem;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-lg);
}

.hero-caption {
  position: absolute;
  bottom: var(--space-2);
  right: var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  color: var(--color-paper);
  background: color-mix(in srgb, var(--color-ink) 65%, transparent);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.post-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.post-note {
  margin: 0 0 var(--space-6);
  padding: var(--space-3) var(--space-4);
  background: var(--color-highlight);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

.post-nav {
  margin-top: var(--space-8);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

/* ============================================================
   13 · GRID UTILITIES
   ============================================================ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-4);
}

/* ============================================================
   14 · DESIGN SYSTEM PAGE
   ============================================================ */
.ds-intro {
  font-size: var(--text-lg);
  font-style: italic;
  color: var(--text-muted);
  border-left: 3px solid var(--accent);
  padding-left: var(--space-4);
  margin: var(--space-6) 0 var(--space-8);
  line-height: var(--leading-normal);
}

.ds-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-3);
  margin: var(--space-5) 0;
}

.ds-swatch {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ds-swatch-color {
  height: 3.5rem;
}

.ds-swatch-info {
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.ds-swatch-name {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
  word-break: break-all;
}

.ds-swatch-hex {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text);
}

.ds-specimen {
  padding: var(--space-5) var(--space-6);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: var(--space-4) 0;
}

.ds-specimen-label {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

/* headings inside specimens should not carry full page margins */
.ds-specimen h1,
.ds-specimen h2,
.ds-specimen h3,
.ds-specimen h4 {
  margin-top: 0;
}

/* static copy of the header (masthead + nav); styles are shared with section 6 */
.ds-header-replica {
  background: var(--bg-nav);
  border-bottom: 3px double var(--border);
  border-radius: var(--radius);
}

.ds-nav-replica {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
}

/* ============================================================
   15 · APP SHOWCASE
   ============================================================ */
.app-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  margin: var(--space-6) 0;
}

@media (min-width: 36rem) {
  .app-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

.app-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-inset);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.app-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app-icon {
  flex: 0 0 auto;
  width: 3.25rem;
  height: 3.25rem;
  object-fit: cover;
  display: block;
  background: var(--bg-nav);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.app-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: var(--leading-snug);
  color: var(--color-ink);
}

.app-card p {
  margin: 0;
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--text-muted);
  flex: 1;
}

.app-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

.app-store-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-paper);
  background: var(--accent);
  border: 1px solid var(--accent-h);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
  transition: background 0.15s;
}

.app-store-link:hover,
.app-store-link:visited {
  color: var(--color-paper);
}

.app-store-link:hover {
  background: var(--accent-h);
}

/* ============================================================
   16 · DARK SCHEME
   Same tokens, remapped to "lamp-lit parchment". Screen only,
   so printing always uses the light palette.
   ============================================================ */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --color-paper: #1c1610;
    --color-parchment: #2a2118;
    --color-inset: #241c15;
    --color-rule: #4a3c2c;
    --color-rule-strong: #6b5743;
    --color-ink: #efe6d4;
    --color-ink-muted: #bcaa8f;
    --color-ink-faint: #8a785f;
    --color-accent: #d8a878;
    --color-accent-dark: #f0c99d;
    --color-visited: #c49f7b;
    --color-highlight: #3b2f1f;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45);
  }
}

/* ============================================================
   17 · REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  a,
  header nav a,
  .footer-links a,
  .post-card,
  .post-card-thumb img,
  .app-store-link {
    transition: none;
  }

  .post-card:hover,
  .post-card:focus-within,
  .post-card:hover .post-card-thumb img {
    transform: none;
  }
}

/* ============================================================
   18 · PRINT
   ============================================================ */
@media print {
  /* keep the browser's canvas light even when the OS is in dark mode */
  :root {
    color-scheme: light;
  }

  header,
  footer,
  .post-share,
  .post-nav {
    display: none;
  }

  body {
    display: block;
    min-height: 0;
    background: none;
    font-size: 11pt;
    line-height: var(--leading-normal);
  }

  .container {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  a,
  a:visited {
    color: inherit;
  }

  .post-card,
  .app-card {
    box-shadow: none;
  }

  h1,
  h2,
  h3 {
    break-after: avoid;
  }

  .post-card,
  .app-card,
  pre,
  blockquote,
  table {
    break-inside: avoid;
  }
}
