/* Samuele Castellani — personal site
   Palette: black, bone, ash, signal red. Fonts self-hosted (SIL OFL). */

@font-face {
  font-family: "Anton";
  src: url("fonts/Anton-Regular.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Fira Sans";
  src: url("fonts/FiraSans-Regular.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Fira Sans";
  src: url("fonts/FiraSans-Medium.woff") format("woff");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Fira Sans";
  src: url("fonts/FiraSans-Italic.woff") format("woff");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --black: #000000;
  --bone: #ece8e2;
  --ash: #948e88;
  --red: #e3122b;
  --red-bright: #ff3348;
  --line: #262424;

  --display: "Anton", "Impact", "Arial Narrow", sans-serif;
  --body: "Fira Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --gutter: clamp(20px, 5vw, 64px);
  --max: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--black);
  color: var(--bone);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ol, ul, dl, dd, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a { color: inherit; text-decoration-color: var(--red); text-underline-offset: 0.2em; }
a:hover { color: var(--red-bright); }

:focus-visible { outline: 2px solid var(--red-bright); outline-offset: 3px; }

.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.muted { color: var(--ash); }

.skip {
  position: absolute; left: var(--gutter); top: -100px;
  background: var(--red); color: var(--black); padding: 0.5em 1em; font-weight: 500;
}
.skip:focus { top: 12px; }

h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0.005em;
}
h3 { font-size: 1.15rem; font-weight: 500; line-height: 1.3; }

/* ---------------- Hero ---------------- */

.hero {
  position: relative;
  overflow: hidden;
  min-height: 94svh;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}
.hero__inner {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: clamp(28px, 5vh, 56px);
  padding-block: clamp(40px, 9vh, 96px) clamp(24px, 4vh, 40px);
}

.name {
  align-self: end;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.6rem, 18vw, 9.5rem);
  line-height: 0.9;
  letter-spacing: -0.005em;
  text-transform: none;
}

.hero__text { max-width: 36rem; display: grid; gap: 0.9rem; }
.lede { font-size: clamp(1.25rem, 2.2vw, 1.5rem); font-weight: 500; line-height: 1.35; }
.hero__text > p:not(.lede) { color: var(--ash); }

.hero__links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 0.6rem; }
.btn {
  display: inline-block;
  padding: 0.6em 1.15em;
  border: 1px solid var(--bone);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.98rem;
  line-height: 1.2;
}
.btn:hover { border-color: var(--red-bright); color: var(--red-bright); }
.btn--solid { background: var(--red); border-color: var(--red); color: var(--black); }
.btn--solid:hover { background: var(--red-bright); border-color: var(--red-bright); color: var(--black); }

.hero__meta { color: var(--ash); font-size: 0.92rem; }

/* Bit cascade (assets/hero.js). Without JS the name simply fades in. */
.hero__inner { position: relative; z-index: 1; }
.bits { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.name__line { display: block; width: fit-content; }
.name__line + .name__line { color: var(--red); }
.name { opacity: 0; animation: name-in 0.5s ease 0.6s forwards; }
.name--pending { animation: none; opacity: 0; }
.name--formed { opacity: 1; transition: opacity 0.45s ease; }
@keyframes name-in { to { opacity: 1; } }

/* ---------------- Path ---------------- */

.path { padding-block: clamp(72px, 12vh, 140px); border-bottom: 1px solid var(--line); }
.path__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 48px;
}
.path__head { display: grid; gap: 0.6rem; align-content: start; }

.timeline { display: grid; gap: 0; border-left: 2px solid var(--line); }
.timeline li {
  position: relative;
  display: grid;
  gap: 0.35rem;
  padding: 0 0 2.4rem 1.6rem;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px; top: 0.45em;
  width: 12px; height: 12px;
  background: var(--black);
  border: 2px solid var(--ash);
}
.timeline li:first-child::before { background: var(--red); border-color: var(--red); }
.timeline__when {
  font-family: var(--display);
  font-size: 1.35rem;
  line-height: 1.1;
  color: var(--red);
  letter-spacing: 0.01em;
}
.timeline p { max-width: 38rem; }
.where { color: var(--ash); font-size: 0.95rem; }

.quote {
  border-left: 4px solid var(--red);
  padding: 0.2rem 0 0.2rem 1.4rem;
  display: grid;
  gap: 0.6rem;
}
.quote p {
  font-family: var(--display);
  font-size: clamp(1.7rem, 3.6vw, 2.5rem);
  line-height: 1.08;
}
.quote footer { color: var(--ash); max-width: 34rem; }

.skills { display: grid; gap: 1.2rem 2rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.skills div { border-top: 1px solid var(--line); padding-top: 0.8rem; }
.skills dt { font-weight: 500; margin-bottom: 0.25rem; }
.skills dd { color: var(--ash); font-size: 0.95rem; }

@media (min-width: 900px) {
  .path__grid { grid-template-columns: 300px minmax(0, 1fr); column-gap: 72px; row-gap: 72px; }
  .path__head { position: sticky; top: 40px; grid-row: span 2; }
  .skills { grid-column: 1 / -1; }
}

/* ---------------- Horizontal rows ---------------- */

.row { padding-block: clamp(56px, 9vh, 96px); border-bottom: 1px solid var(--line); }
.row__head { display: grid; gap: 0.5rem; margin-bottom: 28px; }

.rail {
  --inset: max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter)));
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(340px, 80vw);
  gap: 18px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--inset);
  padding: 4px var(--inset) 22px;
}

/* Without JS: thin native scrollbar. With JS (assets/rails.js): native bar hidden,
   replaced by a small centered indicator that can be dragged or clicked. */
.rail { scrollbar-width: thin; scrollbar-color: #7a0f1b transparent; }
.rail--js { scrollbar-width: none; padding-bottom: 6px; }
.rail--js::-webkit-scrollbar { display: none; }
.rail--dragging { scroll-snap-type: none; }

.rail-bar {
  position: relative;
  width: 140px;
  height: 20px;
  margin: 14px auto 0;
  cursor: pointer;
  touch-action: none;
}
.rail-bar[hidden] { display: none; }
.rail-bar::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  margin-top: -1px;
  background: var(--line);
}
.rail-bar__thumb {
  position: absolute;
  left: 0; top: 50%;
  height: 4px;
  margin-top: -2px;
  background: var(--red);
  will-change: transform;
}
.rail-bar:hover .rail-bar__thumb { background: var(--red-bright); }

.card {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 22px 22px 24px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--ash);
}
.card--live { border-top-color: var(--red); }
.card__status { font-size: 0.88rem; color: var(--ash); font-weight: 500; }
.card--live .card__status { color: var(--red-bright); }
.card > p:not(.card__status):not(.tags) { color: #cfcac3; font-size: 0.98rem; }
.tags { margin-top: auto; padding-top: 0.6rem; font-size: 0.86rem; color: var(--ash); font-style: italic; }
.card__link { font-weight: 500; font-size: 0.95rem; margin-top: auto; padding-top: 0.4rem; }
.card--call { border-color: var(--red); background: rgba(227, 18, 43, 0.07); }

/* ---------------- Contact ---------------- */

.contact { padding-block: clamp(72px, 12vh, 130px) 40px; }
.contact h2 { margin-bottom: 2rem; }
.contact__list { border-top: 1px solid var(--line); }
.contact__list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  font-family: var(--display);
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1;
}
.contact__list a:hover { color: var(--red-bright); }
.contact__handle { font-family: var(--body); font-size: 1rem; color: var(--ash); }
.contact__list a:hover .contact__handle { color: var(--bone); }

.colophon { margin-top: 3rem; font-size: 0.88rem; color: var(--ash); max-width: 40rem; }

/* ---------------- Motion & print ---------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .name, .name--pending { animation: none; opacity: 1; }
  .bits { display: none; }
}

@media print {
  body { background: #fff; color: #000; }
  .bits, .skip, .rail-bar { display: none; }
  .rail { overflow: visible; grid-auto-flow: row; padding-inline: 0; }
}

/* ---------------- 404 ---------------- */
.notfound { min-height: 100svh; display: grid; align-content: center; gap: 1.6rem; }
