@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,300;1,9..144,400;1,9..144,500&display=swap');

:root {
  --display: 'Fraunces', Georgia, serif;
  --body: 'EB Garamond', Georgia, serif;
  --sans: -apple-system, 'Helvetica Neue', Helvetica, sans-serif;

  --bg: #fff;
  --text: #111;
  --mid: #555;
  --dim: #999;
  --rule: #e2e2e2;
  --red: #D63230;
  --progress: #D63230;
}

[data-theme="dark"] {
  --bg: #111;
  --text: #e8e8e8;
  --mid: #aaa;
  --dim: #666;
  --rule: #2a2a2a;
  --red: #E05550;
  --progress: #E05550;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
::selection { background: rgba(214, 50, 48, .12); }

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

body {
  font-family: var(--body);
  font-size: 1.1rem;
  line-height: 1.72;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--red);
  z-index: 100;
}

/* --- Layout --- */

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Header --- */

.hd {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2rem 0 0;
  margin-bottom: 1rem;
}

.hd-name {
  font-family: var(--display);
  font-size: .95rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text);
  text-decoration: none;
}
.hd-name:hover { color: var(--red); }

.hd-r {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.hd-link {
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 400;
  color: var(--dim);
  text-decoration: none;
}
.hd-link:hover { color: var(--text); }

.hd-toggle {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: .85rem;
  color: var(--dim);
  padding: 0;
  line-height: 1;
}
.hd-toggle:hover { color: var(--text); }

/* The red line — a quiet signature */
.hd-rule {
  border: none;
  height: 2px;
  background: var(--red);
  margin: 1.2rem 0 3.5rem;
}

/* --- Post List (Homepage) --- */

.posts {
  padding-bottom: 5rem;
}

.posts a {
  display: flex;
  align-items: baseline;
  gap: 1.4rem;
  text-decoration: none;
  color: inherit;
  padding: 1.6rem 0;
}

.posts a + a {
  border-top: 1px solid var(--rule);
}

/* Issue number — the twist */
.posts .num {
  font-family: var(--sans);
  font-size: .65rem;
  color: var(--dim);
  min-width: 1.4rem;
  text-align: right;
  padding-top: .25rem;
  flex-shrink: 0;
}

.posts .entry {
  flex: 1;
}

.posts h2 {
  font-family: var(--display);
  font-size: 2.8rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -.02em;
  margin-bottom: .3rem;
  position: relative;
  display: inline;
  background-image: linear-gradient(var(--red), var(--red));
  background-size: 0% 1.5px;
  background-position: 0 92%;
  background-repeat: no-repeat;
  transition: background-size .35s cubic-bezier(.4, 0, .2, 1);
}

.posts a:hover h2 {
  background-size: 100% 1.5px;
}

.posts .date {
  display: block;
  font-family: var(--sans);
  font-size: .73rem;
  color: var(--dim);
  margin-top: .25rem;
}

/* --- Post Page --- */

.post-back {
  display: inline-block;
  font-family: var(--sans);
  font-size: .75rem;
  color: var(--dim);
  text-decoration: none;
  margin-bottom: 3rem;
}
.post-back:hover { color: var(--red); }

.post-date {
  font-family: var(--sans);
  font-size: .75rem;
  color: var(--dim);
  margin-bottom: .6rem;
}

.post-title {
  font-family: var(--display);
  font-size: 4rem;
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -.03em;
  margin-bottom: 2.5rem;
}

/* thin red rule before body */
.post-body::before {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  background: var(--red);
  margin-bottom: 2.5rem;
}

/* --- Post Body --- */

.post-body {
  padding-bottom: 4rem;
  font-size: 1.3rem;
  line-height: 1.75;
}

.post-body h1 { display: none; }

.post-body h2 {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 400;
  margin: 2.8rem 0 1rem;
}

.post-body h3 {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 500;
  margin: 2.2rem 0 .8rem;
}

.post-body p {
  margin-bottom: 1.4rem;
  text-align: justify;
  text-align-last: left;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.post-body blockquote {
  border-left: 2px solid var(--red);
  padding-left: 1.3rem;
  margin: 1.6rem 0;
  color: var(--mid);
  font-style: italic;
}

.post-body a {
  color: var(--text);
  text-decoration-color: var(--red);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.post-body a:hover {
  color: var(--red);
}

.post-body ul, .post-body ol {
  margin: 1.2rem 0;
  padding-left: 1.3rem;
}

.post-body li {
  margin-bottom: .4rem;
}

.post-body code {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: .82em;
  background: var(--rule);
  padding: .1em .3em;
  border-radius: 2px;
}

.post-body pre {
  background: var(--rule);
  padding: 1rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: 2px;
  font-size: .82rem;
  line-height: 1.55;
}

.post-body pre code {
  background: none;
  padding: 0;
}

.post-body hr {
  border: none;
  height: 2px;
  background: var(--red);
  margin: 2.5rem auto;
  width: 40px;
}

/* Drop cap */
.post-body > p:first-of-type::first-letter {
  font-family: var(--display);
  font-weight: 600;
  font-size: 3.8em;
  float: left;
  line-height: .8;
  padding-right: .08em;
  margin-right: .02em;
  margin-top: .05em;
  color: var(--red);
}

.post-body em { font-style: italic; }
.post-body strong { font-weight: 600; }

/* --- Post Nav --- */

.post-nav {
  border-top: 1px solid var(--rule);
  padding: 2rem 0 4rem;
  display: flex;
  justify-content: space-between;
  gap: 2rem;
}

.post-nav a {
  font-family: var(--sans);
  font-size: .8rem;
  color: var(--dim);
  text-decoration: none;
  max-width: 50%;
}
.post-nav a:hover { color: var(--text); }

.post-nav .label {
  display: block;
  font-size: .7rem;
  color: var(--dim);
  margin-bottom: .25rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.post-nav .title {
  font-family: var(--display);
  font-size: 1rem;
  color: var(--text);
  font-weight: 400;
}
.post-nav a:hover .title { color: var(--red); }

/* --- About --- */

.about {
  padding: 0 0 5rem;
}

.about h1 {
  font-family: var(--display);
  font-size: 2.4rem;
  font-weight: 400;
  margin-bottom: 1.5rem;
}

.about p {
  color: var(--mid);
  margin-bottom: 1.2rem;
  max-width: 480px;
  line-height: 1.75;
}

.about a {
  color: var(--text);
  text-decoration-color: var(--red);
  text-underline-offset: 2px;
}
.about a:hover { color: var(--red); }

/* --- Footer --- */

.ft {
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: .72rem;
  color: var(--dim);
}

.ft a {
  color: var(--dim);
  text-decoration: none;
}
.ft a:hover { color: var(--red); }

/* --- Responsive --- */

@media (max-width: 600px) {
  html { font-size: 17px; }
  .wrap { padding: 0 1.2rem; }
  .hd { margin-bottom: .8rem; }
  .hd-rule { margin-bottom: 2.5rem; }
  .posts a { gap: 1rem; }
  .posts h2 { font-size: 2rem; }
  .post-title { font-size: 2.8rem; }
  .post-nav { flex-direction: column; gap: 1.2rem; }
  .post-nav a { max-width: 100%; }
  .about h1 { font-size: 1.8rem; }
  .ft { flex-direction: column; align-items: flex-start; gap: .3rem; }
}

/* --- View Transitions --- */

@view-transition {
  navigation: auto;
}

/* Title: container moves + resizes, text crossfades (no stretch) */
::view-transition-group(post-title) {
  animation-duration: .35s;
  animation-timing-function: cubic-bezier(.4, 0, .1, 1);
}

::view-transition-old(post-title) {
  animation: vt-title-out .2s ease both;
}

::view-transition-new(post-title) {
  animation: vt-title-in .25s ease .1s both;
}

@keyframes vt-title-out {
  to { opacity: 0; }
}

@keyframes vt-title-in {
  from { opacity: 0; }
}

/* Header + rule persist without animation */
.hd { view-transition-name: header; }
.hd-rule { view-transition-name: header-rule; }

::view-transition-old(header),
::view-transition-new(header),
::view-transition-old(header-rule),
::view-transition-new(header-rule) {
  animation: none;
}

/* Subtle crossfade for the rest of the page */
::view-transition-old(root) {
  animation: vt-out .3s ease both;
}
::view-transition-new(root) {
  animation: vt-in .3s ease .05s both;
}

@keyframes vt-out {
  to { opacity: 0; }
}
@keyframes vt-in {
  from { opacity: 0; }
}

/* --- Scroll-Driven Title Scaling --- */

@supports (animation-timeline: view()) {
  .posts a {
    animation: title-breathe linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 100%, exit 0% exit 100%;
  }

  @keyframes title-breathe {
    0%   { opacity: .65; transform: scale(.96); }
    25%  { opacity: 1;   transform: scale(1); }
    75%  { opacity: 1;   transform: scale(1); }
    100% { opacity: .65; transform: scale(.96); }
  }

  .posts a {
    transform-origin: left center;
    will-change: transform, opacity;
  }
}

@media print {
  .progress-bar, .hd-toggle, .post-back, .post-nav { display: none; }
}
