/* ==========================================================================
   sebastiantirelli.com — editorial research-notebook design system
   Fraunces (display + body) · JetBrains Mono (code/data)
   Warm cream + deep ink + rust accent · dark mode automatic
   ========================================================================== */

:root {
  /* Typography */
  --serif: "Fraunces", ui-serif, Charter, Georgia, "Iowan Old Style", serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  /* Light mode — warm paper */
  --bg: #f7f2e8;
  --bg-subtle: #efe9dc;
  --bg-inset: #ebe4d2;
  --ink: #141310;
  --ink-muted: #4a463d;
  --ink-faint: #8b8577;
  --rule: #d4ccb9;
  --rust: #b8502a;
  --rust-dark: #933f20;

  /* Scale */
  --step--2: clamp(0.72rem, 0.70rem + 0.10vw, 0.78rem);
  --step--1: clamp(0.83rem, 0.80rem + 0.15vw, 0.92rem);
  --step-0:  clamp(1.00rem, 0.95rem + 0.25vw, 1.12rem);
  --step-1:  clamp(1.20rem, 1.14rem + 0.30vw, 1.35rem);
  --step-2:  clamp(1.44rem, 1.36rem + 0.40vw, 1.63rem);
  --step-3:  clamp(1.73rem, 1.62rem + 0.55vw, 1.95rem);
  --step-4:  clamp(2.07rem, 1.93rem + 0.70vw, 2.34rem);
  --step-5:  clamp(2.49rem, 2.30rem + 0.95vw, 2.81rem);
  --step-6:  clamp(3.05rem, 2.78rem + 1.35vw, 3.60rem);

  /* Rhythm */
  --content-max: 720px;
  --reading-max: 680px;
  --wide-max: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130e;
    --bg-subtle: #1c1a14;
    --bg-inset: #22201a;
    --ink: #ede8dc;
    --ink-muted: #a39f95;
    --ink-faint: #6d6a60;
    --rule: #36332d;
    --rust: #d86838;
    --rust-dark: #b8502a;
  }
}

/* ==========================================================================
   Reset + base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }

body {
  margin: 0;
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  font-variation-settings: "SOFT" 40, "WONK" 0;
  font-feature-settings: "ss01" on, "liga" on, "kern" on;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle grain texture for warmth */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/><feColorMatrix values='0 0 0 0 0.08 0 0 0 0 0.08 0 0 0 0 0.08 0 0 0 0.04 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) {
  body::before {
    mix-blend-mode: screen;
    opacity: 0.35;
  }
}

/* ==========================================================================
   Links
   ========================================================================== */

a {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(to top, var(--rust) 0 1px, transparent 1px);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  transition: color 0.2s, background-size 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
a:hover {
  color: var(--rust);
  background-size: 100% 40%;
}
a.bare {
  background-image: none;
}
a.bare:hover {
  color: var(--rust);
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ink);
  font-variation-settings: "SOFT" 30, "opsz" 144;
}

h1 { font-size: var(--step-6); font-weight: 600; letter-spacing: -0.03em; }
h2 { font-size: var(--step-3); margin-top: 2.5em; margin-bottom: 0.6em; }
h3 { font-size: var(--step-2); margin-top: 2em; margin-bottom: 0.5em; }
h4 { font-size: var(--step-1); margin-top: 1.5em; margin-bottom: 0.4em; }

p { margin: 0 0 1.2em; }

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

small, .small {
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.eyebrow {
  font-family: var(--mono);
  font-size: var(--step--2);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--rust);
  display: inline-block;
  margin-bottom: 1em;
}

code, .mono {
  font-family: var(--mono);
  font-size: 0.9em;
  font-feature-settings: "liga" 0, "calt" 0;
}
p code, li code {
  background: var(--bg-inset);
  padding: 0.1em 0.35em;
  border-radius: 2px;
  font-size: 0.88em;
}

pre {
  font-family: var(--mono);
  font-size: var(--step--1);
  line-height: 1.55;
  background: var(--bg-inset);
  color: var(--ink);
  padding: 1.2em 1.4em;
  overflow-x: auto;
  border-left: 2px solid var(--rust);
  margin: 1.5em 0;
}
pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

blockquote {
  margin: 1.5em 0;
  padding-left: 1.5em;
  border-left: 2px solid var(--rust);
  font-style: italic;
  color: var(--ink-muted);
}

hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 3em 0;
}

/* Decorative section divider */
.divider {
  text-align: center;
  margin: 3em 0;
  color: var(--rule);
  font-size: var(--step--1);
  letter-spacing: 1em;
}

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.container {
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 0 clamp(1.2rem, 4vw, 2.5rem);
}
.reading {
  max-width: var(--reading-max);
  margin: 0 auto;
  padding: 0 clamp(1.2rem, 4vw, 2.5rem);
}

/* ==========================================================================
   Top bar (masthead)
   ========================================================================== */

.masthead {
  border-bottom: 1px solid var(--rule);
  padding: 1.4rem 0;
  margin-bottom: 4rem;
}
.masthead__inner {
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 0 clamp(1.2rem, 4vw, 2.5rem);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}
.masthead__brand {
  font-family: var(--serif);
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.masthead__brand::before {
  content: "§ ";
  color: var(--rust);
  margin-right: 0.15em;
}
.masthead__brand {
  background-image: none;
}
.masthead__brand:hover {
  color: var(--rust);
}

.masthead__nav {
  display: flex;
  gap: 1.8rem;
  font-family: var(--mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.masthead__nav a {
  color: var(--ink-muted);
  background-image: none;
}
.masthead__nav a:hover,
.masthead__nav a[aria-current="page"] {
  color: var(--rust);
}

/* ==========================================================================
   Hero (home)
   ========================================================================== */

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
  align-items: start;
  margin-bottom: 4rem;
}
@media (min-width: 720px) {
  .hero {
    grid-template-columns: 200px 1fr;
    gap: 3rem;
  }
}
.hero__portrait {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  filter: grayscale(0.2) contrast(1.05);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 var(--bg-subtle), 0 12px 28px rgba(0,0,0,0.08);
}
@media (prefers-color-scheme: dark) {
  .hero__portrait {
    box-shadow: 0 1px 0 var(--bg-subtle), 0 12px 28px rgba(0,0,0,0.5);
  }
}
.hero__lede {
  font-size: var(--step-2);
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-weight: 400;
  margin-bottom: 1em;
  font-variation-settings: "SOFT" 30, "opsz" 80;
}
.hero__support {
  font-size: var(--step-0);
  color: var(--ink-muted);
  max-width: 58ch;
}
.hero__name {
  font-family: var(--mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--rust);
  margin-bottom: 0.5em;
  display: inline-block;
}

/* ==========================================================================
   Section
   ========================================================================== */

.section {
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 3rem clamp(1.2rem, 4vw, 2.5rem);
  border-top: 1px solid var(--rule);
}
.section__head {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 2rem;
}
.section__label {
  font-family: var(--mono);
  font-size: var(--step--2);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--rust);
}
.section__title {
  font-size: var(--step-3);
  letter-spacing: -0.02em;
}
.section__body {
  max-width: 66ch;
  color: var(--ink-muted);
}

/* ==========================================================================
   Project cards
   ========================================================================== */

.projects {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}
@media (min-width: 780px) {
  .projects { grid-template-columns: 1fr 1fr; }
}

.project {
  display: block;
  padding: 1.8rem 1.8rem 2rem;
  background: var(--bg-subtle);
  border: 1px solid var(--rule);
  background-image: none;
  position: relative;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s;
}
.project:hover {
  transform: translateY(-3px);
  border-color: var(--rust);
  color: var(--ink);
}
.project__meta {
  font-family: var(--mono);
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  margin-bottom: 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.project__meta strong {
  color: var(--rust);
  font-weight: 500;
}
.project__title {
  font-size: var(--step-2);
  font-weight: 500;
  letter-spacing: -0.015em;
  margin-bottom: 0.6rem;
  color: var(--ink);
}
.project__desc {
  color: var(--ink-muted);
  font-size: var(--step-0);
  line-height: 1.55;
  margin-bottom: 1rem;
}
.project__arrow {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--rust);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ==========================================================================
   Writing list
   ========================================================================== */

.writing {
  display: grid;
  gap: 0;
}
.writing__entry {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  padding: 1.4rem 0;
  border-top: 1px solid var(--rule);
  background-image: none;
  color: var(--ink);
}
.writing__entry:last-child {
  border-bottom: 1px solid var(--rule);
}
.writing__entry:hover {
  color: var(--rust);
}
@media (min-width: 720px) {
  .writing__entry {
    grid-template-columns: 110px 1fr;
    gap: 2rem;
  }
}
.writing__date {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  padding-top: 0.2em;
}
.writing__title {
  font-size: var(--step-1);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 0.3em;
}
.writing__excerpt {
  color: var(--ink-muted);
  font-size: var(--step-0);
  line-height: 1.55;
}

.writing__soon {
  padding: 1.4rem 0;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-style: italic;
}

/* ==========================================================================
   Elsewhere (social links)
   ========================================================================== */

.elsewhere {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem 2.4rem;
  font-family: var(--mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.elsewhere a {
  color: var(--ink-muted);
}
.elsewhere a:hover {
  color: var(--rust);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  margin-top: 6rem;
  padding: 2.5rem clamp(1.2rem, 4vw, 2.5rem);
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--ink-faint);
  text-align: center;
}
.footer__glyph {
  font-family: var(--serif);
  color: var(--rust);
  font-size: var(--step-1);
  display: block;
  margin-bottom: 0.8rem;
  letter-spacing: 0.5em;
}

/* ==========================================================================
   Blog post layout
   ========================================================================== */

.post {
  max-width: var(--reading-max);
  margin: 0 auto;
  padding: 2rem clamp(1.2rem, 4vw, 2.5rem) 4rem;
}
.post__meta {
  font-family: var(--mono);
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--rust);
  margin-bottom: 1.5em;
  display: flex;
  gap: 1.4em;
  flex-wrap: wrap;
}
.post__meta span::before {
  content: "§ ";
  color: var(--ink-faint);
}
.post__title {
  font-size: var(--step-5);
  letter-spacing: -0.025em;
  line-height: 1.08;
  margin-bottom: 0.8em;
  font-weight: 600;
  font-variation-settings: "SOFT" 20, "opsz" 144;
}
.post__standfirst {
  font-size: var(--step-1);
  color: var(--ink-muted);
  line-height: 1.45;
  margin-bottom: 2.5em;
  font-style: italic;
  font-variation-settings: "SOFT" 40, "opsz" 100;
}

.post__body {
  font-size: var(--step-0);
  line-height: 1.7;
  color: var(--ink);
}
.post__body > p:first-of-type::first-letter {
  font-family: var(--serif);
  font-size: 4.2em;
  font-weight: 500;
  float: left;
  line-height: 0.88;
  padding-right: 0.1em;
  padding-top: 0.1em;
  color: var(--rust);
  font-variation-settings: "SOFT" 20, "opsz" 144;
}

.post__body h2 {
  font-size: var(--step-2);
  margin-top: 2.4em;
  margin-bottom: 0.6em;
}
.post__body h3 {
  font-size: var(--step-1);
  margin-top: 1.8em;
  margin-bottom: 0.4em;
}

.post__body a {
  color: var(--ink);
  background-image: linear-gradient(to top, var(--rust) 0 1px, transparent 1px);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: 0 95%;
}
.post__body a:hover {
  color: var(--rust);
  background-size: 100% 30%;
}

.post__body ul, .post__body ol {
  padding-left: 1.4em;
  margin: 1em 0 1.4em;
}
.post__body li {
  margin-bottom: 0.4em;
}

.post__body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.8em 0;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}
.post__body th, .post__body td {
  text-align: left;
  padding: 0.6em 0.9em;
  border-bottom: 1px solid var(--rule);
}
.post__body th {
  font-family: var(--mono);
  font-weight: 500;
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  border-bottom-color: var(--ink);
}

.post__body figure {
  margin: 2em 0;
  padding: 1.4em;
  background: var(--bg-subtle);
  border-left: 2px solid var(--rust);
}
.post__body figcaption {
  font-family: var(--mono);
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  margin-top: 0.8em;
}

.post__nav {
  margin-top: 5em;
  padding-top: 2em;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 1.5em;
  font-family: var(--mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.post__nav a {
  color: var(--ink-muted);
  background-image: none;
}
.post__nav a:hover { color: var(--rust); }

/* ==========================================================================
   Utility
   ========================================================================== */

.prose-max {
  max-width: 66ch;
}

/* Page-load fade-in (minimal, respectful) */
@media (prefers-reduced-motion: no-preference) {
  body {
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
  }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
