/* =========================================================
   Brad Hakes — writing site (the catchall notebook)
   Companion to the curated substack "Imagination Compact"

   Design system:
     - Warm paper-tone palette (light & dark modes both warm)
     - Serif body & titles (Iowan / Palatino stack)
     - System sans-serif for the contact card
     - Mono for dates
     - Single column, ~420px, centered
     - Hover-reveal dates on desktop; always-visible dates on mobile
     - Sun/moon toggle anchored to the column's top-right corner,
       optically centered on the corner (translate -50%, +50%)
   ========================================================= */

/* ---------- Reset & base ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; }

/* ---------- Theme colors ---------- */
.page {
  --paper: #f6f3ec;     /* warm off-white */
  --ink: #2a2924;       /* deep warm black */
  --rule: rgba(42, 41, 36, 0.18);
  --muted: rgba(42, 41, 36, 0.45);

  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  padding: 4rem 1.5rem 4rem;
  transition: background-color 0.4s ease, color 0.4s ease;
}

.page.dark {
  --paper: #14140f;
  --ink: #e6e2d6;
  --rule: rgba(230, 226, 214, 0.18);
  --muted: rgba(230, 226, 214, 0.45);
}

/* ---------- Reading column ---------- */
.column {
  max-width: 420px;
  margin: 0 auto;
  position: relative;
  padding-top: 1.25rem;
}

/* ---------- Toggle ----------
   Position locked across ALL interaction states so the browser
   can't apply its default click-press transform (which would
   cause the icon to "jump" toward the center on click).
   The hover/active scale effect lives on the SVG, not the button.
*/
.toggle,
.toggle:hover,
.toggle:focus,
.toggle:active,
.toggle:focus-visible,
.toggle:focus-within {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%) !important;
  cursor: pointer;
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding: 0;
  margin: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.toggle svg {
  display: block;
  transition: transform 0.2s ease;
  transform-origin: center center;
}

.toggle:hover svg { transform: scale(1.12); }
.toggle:active svg { transform: scale(1.04); }

/* Show sun in light mode, moon in dark mode */
.toggle .moon { display: none; }
.toggle.is-dark .sun { display: none; }
.toggle.is-dark .moon { display: block; }

/* Hard-code stroke per mode (avoids inheritance / emoji-render issues) */
.page .toggle svg circle,
.page .toggle svg line,
.page .toggle svg path { stroke: #2a2924; }
.page.dark .toggle svg circle,
.page.dark .toggle svg line,
.page.dark .toggle svg path { stroke: #e6e2d6; }

/* ---------- Masthead (contact card) ---------- */
.masthead {
  margin-bottom: 3rem;
}

.links {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 6px 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  font-size: 12px;
  margin: 0;
}

.links dt {
  color: var(--muted);
  letter-spacing: 0.04em;
}

.links dd { margin: 0; }

.links dd a {
  text-decoration: none;
  border-bottom: 0.5px solid currentColor;
  opacity: 0.85;
  transition: opacity 0.2s ease;
  padding-bottom: 1px;
}

.links dd a:hover { opacity: 1; }

/* ---------- Writing list ---------- */
.post-list { }

.post {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-top: 0.5px solid var(--rule);
  text-decoration: none;
  position: relative;
  transition: opacity 0.2s ease;
}

.post:hover { opacity: 0.7; }

.post-title {
  font-size: 16px;
  line-height: 1.4;
  font-weight: 400;
  margin: 0;
  flex: 1;
}

/* Desktop: date hidden by default, appears in right margin on hover */
.post-date {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
  position: absolute;
  right: -64px;
  top: 1rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.post:hover .post-date { opacity: 1; }

/* ---------- Mobile: dates always visible, under the title ---------- */
@media (max-width: 700px) {
  .page {
    padding: 3rem 1.25rem 4rem;
  }

  .post {
    display: block;
    padding: 0.85rem 0;
  }

  .post-date {
    position: static;
    display: block;
    opacity: 0.55;
    margin-top: 4px;
    right: auto;
    top: auto;
  }

  /* On very narrow screens, give the label column a touch more room */
  .links {
    grid-template-columns: 100px 1fr;
  }
}

/* ---------- Selection color (small refinement) ---------- */
::selection {
  background: var(--ink);
  color: var(--paper);
}
