/* ---------------------------------------------------------------
   liamreese.com — "paper notebook" design system  (v0.2)
   Distilled from the Remy iOS app (Theme.swift, 2026-09).
   v0.2: Remy's real polaroid frame (MockPolaroid), geometric washi
   tape, no site chrome — the notebook is the whole page.
   --------------------------------------------------------------- */

/* ---- Fonts (self-hosted; Apache 2.0 / OFL) ---- */
@font-face {
  font-family: 'Rock Salt';
  src: url('fonts/RockSalt-Regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Walter Turncoat';
  src: url('fonts/WalterTurncoat-Regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Space Mono';
  src: url('fonts/SpaceMono-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Space Mono';
  src: url('fonts/SpaceMono-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

/* ---- Tokens (Theme.swift) ---- */
:root {
  /* grounds */
  --paper:      #EFE9DA;
  --surface:    #F8F5EE;
  --art-well:   #ECE2CD;
  /* inks */
  --ink:        #595959;
  --ink-strong: #484744;
  --ink-muted:  #928D83;
  /* accents */
  --sienna:     #A96B29;  /* decoration — never interactive */
  --blue:       #1155CC;  /* action — never decorative */
  /* supporting */
  --rule:       #878278;
  --red-ink:    #8E3B2C;
  --photo-well: #1B1A19;
  --margin-red: #D9A49A;

  /* space (Theme.Space) */
  --s-xs: 4px; --s-s: 8px; --s-m: 16px; --s-l: 24px; --s-xl: 32px;

  --radius: 6px;
  --shadow-paper: 3px 4px 8px rgba(51, 48, 42, 0.18);
  --shadow-lift:  5px 8px 16px rgba(51, 48, 42, 0.22);

  --f-name: 'Rock Salt', cursive;
  --f-hand: 'Walter Turncoat', 'Comic Sans MS', cursive;
  --f-mono: 'Space Mono', ui-monospace, monospace;

  --tilt: 0deg;
  --washi: #C9B6B9;
}

/* ---- Base ---- */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper) url('paper.png');
  background-size: 262px 370px;
  color: var(--ink);
  font-family: var(--f-hand);
  font-size: 19px;
  line-height: 34px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(17, 85, 204, 0.16); }

h1, h2, h3 { color: var(--ink-strong); font-weight: 400; margin: 0; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.mono-label {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* ---- Ink rules: blue is action ---- */
a {
  color: var(--blue);
  text-decoration-color: rgba(17, 85, 204, 0.45);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
a:hover { text-decoration-color: var(--blue); }

:focus-visible {
  outline: 2px dashed var(--blue);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---- Washi tape (geometric grid) ----
   Position, length, angle, and piece count come from the build,
   hash-seeded per post — random-looking, stable across rebuilds. */
.tape {
  position: absolute;
  width: 94px;
  height: 26px;
  top: -12px;
  left: 34%;
  z-index: 2;
  background-color: var(--washi);
  background-image:
    repeating-linear-gradient(to right,  rgba(255, 255, 255, 0.65) 0 1.5px, transparent 1.5px 9px),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.65) 0 1.5px, transparent 1.5px 9px);
  opacity: 0.85;
  box-shadow: 0 1px 2px rgba(51, 48, 42, 0.18);
  clip-path: polygon(0 6%, 3% 0, 97% 4%, 100% 0, 100% 94%, 96% 100%, 4% 97%, 0 100%);
}

/* ---- Polaroid: Remy's MockPolaroid frame, art composited in the well ----
   Well geometry measured from the asset (360×360, transparent margins):
   well left 15.8% / top 11.1% / w 68.1% / h 64.4%; chin below the well. */
.polaroid {
  position: relative;
  transform: rotate(var(--tilt));
  filter: drop-shadow(3px 5px 7px rgba(51, 48, 42, 0.28));
}
.polaroid .frame { display: block; width: 100%; height: auto; }
.polaroid .art {
  position: absolute;
  left: 15.8%; top: 11.1%;
  width: 68.1%; height: 64.5%;
  background: var(--art-well);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.polaroid .art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.polaroid .art.art-contain img { object-fit: contain; padding: 5%; }
.polaroid .chin {
  /* flush with the photo well: well spans 15.8% -> 83.9% of the frame */
  position: absolute;
  left: 15.8%; right: 16.1%;
  top: 76%; height: 18.2%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  text-align: left;
  overflow: hidden;
}

/* Index card: ruled fallback for posts without a drawing. */
.notecard {
  background:
    repeating-linear-gradient(to bottom,
      transparent 0 27px, rgba(135, 130, 120, 0.22) 27px 28px)
    var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-paper);
  transform: rotate(var(--tilt));
}

/* ---- The notebook field (homepage) ----
   Loose scatter: wide gaps, per-card width / lateral position / vertical
   drop seeded from the slug. DOM order is newest-first, and vertical
   jitter only pushes down, so newer posts always sit above older ones. */
.field {
  max-width: 1080px;
  margin: 0 auto;
  padding: 100px var(--s-l) 150px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 110px 56px;
}
@media (max-width: 719px) {
  .field { padding: 64px var(--s-l) 110px; gap: 84px 32px; }
}

.card {
  position: relative;
  display: block;
  width: min(100%, var(--card-w, 300px));
  justify-self: center;
  text-decoration: none;
  transition: transform 160ms ease-out, filter 160ms ease-out, box-shadow 160ms ease-out;
}
.card .cap {
  display: block;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--f-hand);
  font-size: 14.5px;
  line-height: 26px;
  color: var(--ink);
}
.card .date {
  display: block;
  font-family: var(--f-mono);
  font-size: 10px;
  line-height: 13px;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
}
.card.polaroid:hover { transform: rotate(0deg) translateY(-5px); filter: drop-shadow(5px 9px 13px rgba(51, 48, 42, 0.32)); z-index: 3; }
.card.notecard:hover { transform: rotate(0deg) translateY(-5px); box-shadow: var(--shadow-lift); z-index: 3; }
.card:hover .cap { color: var(--blue); }

/* fallback notecard variant */
.card.notecard { padding: 30px 18px 14px; }
.card.notecard .motif { display: flex; justify-content: center; padding: 8px 0 4px; }
.card.notecard .cap { text-align: center; font-size: 19px; line-height: 25px; margin-top: 8px; }
.card.notecard .date { text-align: center; margin-top: 3px; }

/* ---- Article page ---- */
.page {
  position: relative;
  max-width: 660px;
  margin: 0 auto;
  padding: 34px var(--s-l) 90px;
}
.backlink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  text-decoration: none;
}
.backlink:hover span { text-decoration: underline; text-underline-offset: 4px; }

.post-date {
  margin-top: 40px;
}
.post-title {
  font-family: var(--f-hand);
  font-size: clamp(30px, 5.5vw, 38px);
  line-height: 1.35;
  letter-spacing: 0.05em;
  margin: 6px 0 26px;
}
/* article cover: no frame — the sketch sits directly on the paper */
.post-sketch {
  width: min(200px, 100%);
  margin: 4px 0 40px;
}
.post-sketch img { display: block; width: 100%; height: auto; }

.post-body p, .post-body li { font-size: 19px; line-height: 34px; }
.post-body p { margin: 0 0 34px; }
.post-body ul, .post-body ol { margin: 0 0 34px; padding-left: 28px; }
.post-body h2 {
  font-family: var(--f-hand);
  font-size: 24px;
  letter-spacing: 0.06em;
  margin: 44px 0 20px;
}
.post-body blockquote {
  margin: 0 0 34px;
  padding: 0 0 0 18px;
  border-left: 3px solid var(--sienna);
  color: var(--ink-strong);
}
.post-body code {
  font-family: var(--f-mono);
  font-size: 15px;
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 4px;
}
.post-body pre {
  font-family: var(--f-mono);
  font-size: 14px;
  line-height: 1.7;
  background: var(--surface);
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 14px 18px;
  overflow-x: auto;
  margin: 0 0 34px;
}
.post-body pre code { background: none; padding: 0; }
.post-body hr {
  border: none;
  margin: 44px auto;
}

.signature {
  margin-top: 56px;
  font-family: var(--f-name);
  font-size: 18px;
  color: var(--ink-strong);
  transform: rotate(-1.2deg);
  display: inline-block;
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card.polaroid:hover, .card.notecard:hover { transform: rotate(var(--tilt)); }
}
