/* ========================================
   Val's Newsletter
   Analog · Textural · Grunge-tender
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Special+Elite&family=IBM+Plex+Mono:wght@300;400&display=swap');

:root {
  /* Palette: darkened analog, coffee-stained, charcoal warmth */
  --paper: #d9cfc1;
  --paper-dark: #cbc0af;
  --parchment: #b8aa96;
  --bark: #6e5a40;
  --ink: #1a140e;
  --ink-faded: #3d3228;
  --ink-ghost: #6b5e4e;
  --rust: #8c4a28;
  --moss: #4a5e3e;

  /* Functional */
  --bg: var(--paper);
  --text: var(--ink);
  --text-mid: var(--ink-faded);
  --text-faint: var(--ink-ghost);
  --accent: var(--rust);
  --accent-alt: var(--moss);
  --rule: var(--parchment);

  /* Type */
  --font-body: 'Libre Baskerville', 'Georgia', serif;
  --font-raw: 'Special Elite', 'Courier New', monospace;
  --font-mono: 'IBM Plex Mono', monospace;

  /* Spacing */
  --s1: 0.5rem;
  --s2: 1rem;
  --s3: 1.8rem;
  --s4: 3rem;
  --s5: 5rem;

  --content-w: 640px;

  /* Shadows: design elements only */
  --shadow-sm: 2px 2px 0 rgba(26, 20, 14, 0.12);
  --shadow-md: 4px 4px 0 rgba(26, 20, 14, 0.1);
  --shadow-lg: 6px 6px 0 rgba(26, 20, 14, 0.1);
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

/* --- Paper texture background --- */
body {
  font-family: var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.85;
  overflow-x: hidden;
  position: relative;
}

/* Heavy grain, like old paper under a scanner */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 512px 512px;
}

/* Subtle aged edge vignette */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(26, 20, 14, 0.1) 100%);
}

/* --- Typography --- */
p {
  margin-bottom: var(--s2);
  color: var(--text-mid);
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

a:hover {
  border-bottom-color: var(--accent);
}

/* --- Layout: book page, content left, margin right --- */
.page {
  max-width: var(--content-w);
  margin-left: clamp(2rem, 8vw, 10rem);
  margin-right: auto;
  padding: var(--s4) var(--s3);
  min-height: 100vh;
  position: relative;
}

/* --- Header: minimal, just a mark --- */
.mark {
  font-family: var(--font-raw);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  color: var(--text-faint);
  margin-bottom: var(--s5);
}

.mark a {
  color: inherit;
  border: none;
}

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

/* --- Side nav: fixed right --- */
.side-nav {
  position: fixed;
  right: 2.5rem;
  top: 3rem;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}

.side-nav a {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-decoration: none;
  border: none;
  transition: color 0.2s;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.side-nav a:hover {
  color: var(--text);
}

/* Flower vine trailing from nav */
.nav-vine {
  margin-top: 0.8rem;
  opacity: 0.85;
  flex-shrink: 0;
}

/* --- Floating Hand-Drawn Player (first cassette) --- */
.player-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.5rem 0;
  margin: 0 calc(-1 * var(--s3));
  margin-bottom: var(--s4);
}

.player-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--paper);
  opacity: 0.92;
  z-index: -1;
}

.player {
  max-width: var(--content-w);
  margin: 0 auto;
  position: relative;
  height: 52px;
  filter: url(#sketch);
}

.player-shell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--ink);
}

.svg-reel {
  transform-origin: center;
}

.svg-reel.spinning {
  animation: reel-spin 1.5s linear infinite;
}

@keyframes reel-spin {
  to { transform: rotate(360deg); }
}

.player-controls {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  height: 100%;
  padding: 0 2.5rem;
}

.player-btn {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--ink-faded);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.player-btn:hover {
  border-color: var(--rust);
  color: var(--rust);
}

.player-btn svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-track {
  font-family: var(--font-raw);
  font-size: 0.65rem;
  color: var(--ink-faded);
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-bar {
  width: 100%;
  height: 2px;
  background: var(--parchment);
  cursor: pointer;
  position: relative;
  border-radius: 1px;
}

.player-progress {
  height: 100%;
  width: 0%;
  background: var(--rust);
  border-radius: 1px;
  transition: width 0.1s linear;
}

.player-progress::after {
  content: '';
  position: absolute;
  right: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: var(--rust);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
}

.player-bar:hover .player-progress::after {
  opacity: 1;
}

.player-time {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--ink-ghost);
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
}

@media (max-width: 580px) {
  /* Hide the decorative cassette shell on mobile */
  .player-shell {
    display: none;
  }

  .player-wrap {
    margin: 0;
    padding: 0.6rem 0;
  }

  .player {
    height: auto;
    filter: none;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 0.6rem;
  }

  .player-controls {
    flex-wrap: wrap;
    padding: 0;
    gap: 0;
    height: auto;
  }

  .player-btn {
    width: 32px;
    height: 32px;
    margin-right: 0.6rem;
  }

  .player-btn svg {
    width: 12px;
    height: 12px;
  }

  .player-info {
    flex: 1;
    min-width: 0;
  }

  .player-track {
    font-size: 0.65rem;
    margin-bottom: 0.35rem;
  }

  .player-bar {
    height: 3px;
  }

  .player-time {
    font-size: 0.55rem;
    min-width: 32px;
  }
}

/* --- Date stamp + weather --- */
.date-stamp {
  font-family: var(--font-raw);
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-bottom: var(--s5);
  letter-spacing: 0.05em;
}

.weather {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-faint);
  margin-top: 0.4rem;
  letter-spacing: 0.02em;
  opacity: 0.7;
}

/* --- The core: entry items --- */
.entries {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.entry {
  padding: var(--s3) var(--s2);
  display: flex;
  gap: var(--s3);
  align-items: baseline;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s1);
  background: rgba(203, 192, 175, 0.25);
  box-shadow: var(--shadow-md);
}

.entry:last-child {
  border-bottom: none;
}

.entry-type {
  font-family: var(--font-raw);
  font-size: 0.72rem;
  text-transform: lowercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  min-width: 70px;
  flex-shrink: 0;
  padding-top: 0.15em;
}

.entry-body {
  flex: 1;
  min-width: 0;
}

.entry-title {
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 0.4rem;
}

.entry-note {
  font-size: 0.95rem;
  color: var(--text-mid);
  line-height: 1.75;
  margin: 0;
}

/* --- Visual dividers (organic, not words) --- */
.tear {
  border: none;
  height: 4px;
  margin: var(--s4) 0;
  background-image: url("data:image/svg+xml,%3Csvg width='400' height='4' viewBox='0 0 400 4' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0,2 Q10,0 20,2 T40,2 T60,2 T80,2 T100,2 T120,2 T140,2 T160,2 T180,2 T200,2 T220,2 T240,2 T260,2 T280,2 T300,2 T320,2 T340,2 T360,2 T380,2 T400,2' stroke='%23ddd4c4' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: center;
  opacity: 0.8;
  filter: drop-shadow(2px 2px 0 rgba(26, 20, 14, 0.08));
}

.blot {
  text-align: center;
  margin: var(--s4) 0;
  color: var(--parchment);
  font-size: 1.5rem;
  letter-spacing: 0.8em;
  line-height: 1;
  user-select: none;
}

.stain {
  position: relative;
  margin: var(--s4) 0;
  height: 2px;
}

.stain::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 90px;
  height: 90px;
  background: radial-gradient(ellipse at 40% 40%, var(--parchment), transparent 70%);
  border-radius: 45% 55% 50% 50% / 55% 45% 55% 45%;
  opacity: 0.6;
}

/* --- Inline thought --- */
.thought {
  padding: var(--s3) 0;
  padding-left: var(--s3);
  border-left: 2px solid var(--parchment);
  color: var(--text-mid);
  font-style: italic;
}

.thought + .thought {
  margin-top: var(--s2);
}

/* --- Question / wondering --- */
.question {
  padding: var(--s2) 0;
  color: var(--text-mid);
  font-style: italic;
  position: relative;
  padding-left: var(--s3);
}

.question::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: var(--parchment);
  border-radius: 50%;
}

/* --- Prose block --- */
.prose {
  padding: var(--s3) 0;
}

.prose p {
  color: var(--text-mid);
  margin-bottom: var(--s2);
}

.prose p:last-child {
  margin-bottom: 0;
}

/* --- Footer --- */
.foot {
  margin-top: var(--s5);
  padding: var(--s5) 0 var(--s4);
  border-top: 1px solid var(--rule);
  font-family: var(--font-raw);
  font-size: 1.8rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-align: center;
  opacity: 0.35;
}

/* --- Visitor counter: old-school odometer --- */
.visitor-counter {
  text-align: center;
  margin-top: var(--s2);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-faint);
  letter-spacing: 0.15em;
  opacity: 0.5;
}

.counter-label {
  display: block;
  font-family: var(--font-raw);
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  margin-bottom: 0.3rem;
  opacity: 0.7;
}

.counter-digits {
  display: inline-flex;
  gap: 2px;
}

.counter-digit {
  display: inline-block;
  width: 1.1em;
  height: 1.6em;
  line-height: 1.6em;
  text-align: center;
  background: rgba(26, 20, 14, 0.04);
  border: 1px solid rgba(26, 20, 14, 0.08);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-faint);
}

/* --- Flower doodles --- */
.flowers {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

.flower {
  position: absolute;
  pointer-events: none;
}

/* Muted background flowers: right margin, faded into paper */
.flower-muted { opacity: 0.18; }
/* Mid-tone flowers */
.flower-mid { opacity: 0.3; }
/* Bright pop flowers: warm, vivid */
.flower-pop { opacity: 0.55; }

/* --- Archive page --- */
.archive-group {
  margin-bottom: var(--s4);
}

.archive-month {
  font-family: var(--font-raw);
  font-size: 0.75rem;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  margin-bottom: var(--s2);
  text-transform: lowercase;
}

.archive-entries {
  list-style: none;
}

.archive-entry {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--s1) 0;
  border-bottom: 1px solid var(--rule);
}

.archive-entry:last-child {
  border-bottom: none;
}

.archive-entry a {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  border: none;
}

.archive-entry a:hover {
  color: var(--accent);
}

.archive-entry .date {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-faint);
  flex-shrink: 0;
  margin-left: var(--s2);
}

.archive-title {
  font-family: var(--font-raw);
  font-size: 1rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  margin-bottom: var(--s4);
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .flowers { display: none; }

  .page {
    margin-left: auto;
    margin-right: auto;
  }

  .side-nav {
    position: static;
    flex-direction: row;
    gap: var(--s3);
    margin-bottom: var(--s4);
    padding: var(--s2) var(--s3);
    justify-content: center;
  }

  .side-nav a {
    writing-mode: horizontal-tb;
    font-size: 0.7rem;
  }

  .nav-vine {
    display: none;
  }
}

@media (max-width: 580px) {
  html { font-size: 18px; }

  .page {
    padding: var(--s3) var(--s2);
  }

  .entry {
    flex-direction: column;
    gap: 0.3rem;
  }

  .entry-type {
    min-width: unset;
    font-size: 0.75rem;
  }

  .entry-note {
    font-size: 0.95rem;
    line-height: 1.8;
  }

  .entry-title {
    font-size: 1.05rem;
  }

  .side-nav a {
    font-size: 0.8rem;
  }

  .archive-entry {
    flex-direction: column;
    gap: 0.2rem;
    align-items: flex-start;
  }

  .archive-entry .date {
    margin-left: 0;
  }
}
