/* Castle Murray — one page, no framework. */

:root {
  --ink: #12110e;
  --paper: #efe7d6;
  --copper: #b5693c;
  --moss: #6e8b74;
  --amber: #d08a3a;
  --serif: "Fraunces", "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --pad: clamp(1.25rem, 4vw, 3.5rem);
  --index: 0px;
  --header: 4.5rem;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 1.125rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

body[data-surface="ink"] {
  --chrome: var(--paper);
}

body[data-surface="paper"] {
  --chrome: var(--ink);
}

::selection {
  background: var(--copper);
  color: var(--paper);
}

img {
  max-width: 100%;
  height: auto;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 4px;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.85'/></svg>");
  background-size: 180px 180px;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem var(--pad);
  color: var(--chrome);
  transition: color 0.4s ease;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.brand span {
  text-shadow:
    0 0 1px #efe7d6,
    0 0 10px rgba(239, 231, 214, 0.96),
    0 0 22px rgba(239, 231, 214, 0.78),
    0 0 1px #12110e,
    0 0 10px rgba(18, 17, 14, 0.92),
    0 0 24px rgba(18, 17, 14, 0.7);
}

.mark {
  width: 1.65rem;
  height: 1.65rem;
  display: block;
  fill: currentColor;
}

.write {
  color: inherit;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.chapter-index {
  display: none;
}

main {
  display: block;
}

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--paper);
  background: var(--ink);
  overflow: hidden;
}

.hero-media {
  position: absolute;
  inset: 0;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: 58% 42%;
  animation: ken 18s ease-out both;
}

.hero-scrim {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  background:
    linear-gradient(180deg, rgba(18, 17, 14, 0.28) 0%, rgba(18, 17, 14, 0.05) 36%, rgba(18, 17, 14, 0.78) 100%);
}

.hero-copy {
  padding: 0 var(--pad) clamp(3.5rem, 9vh, 6.5rem);
  max-width: 78rem;
}

.kicker {
  margin: 0 0 0.85rem;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--copper);
}

h1,
h2 {
  margin: 0;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 0.9;
}

h1 {
  font-size: clamp(4.4rem, 12vw, 10.5rem);
  max-width: 14ch;
}

.mask {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  margin-right: 0.18em;
  padding-bottom: 0.06em;
}

.word {
  display: inline-block;
  animation: rise 1.05s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}

.mask:nth-child(1) .word { animation-delay: 0.12s; }
.mask:nth-child(2) .word { animation-delay: 0.24s; }
.mask:nth-child(3) .word { animation-delay: 0.36s; }
.mask:nth-child(4) .word { animation-delay: 0.48s; }

.deck,
.copy p {
  font-size: clamp(1.15rem, 1.6vw, 1.4rem);
  font-weight: 300;
  line-height: 1.45;
  max-width: 36rem;
}

.deck {
  margin: 1.4rem 0 0;
  max-width: 28rem;
  color: rgba(239, 231, 214, 0.88);
}

.chapter {
  position: relative;
  padding: clamp(6.5rem, 16vh, 11rem) var(--pad);
  scroll-margin-top: var(--header);
}

.chapter-paper {
  background: var(--paper);
  color: var(--ink);
}

.chapter-ink {
  background: var(--ink);
  color: var(--paper);
}

.chapter-ink .copy p {
  color: rgba(239, 231, 214, 0.82);
}

h2 {
  font-size: clamp(4rem, 9vw, 8.25rem);
  margin-bottom: 1.1rem;
}

.copy p {
  margin: 0;
}

.sites-layout,
.servers-layout,
.fixes-layout {
  display: grid;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: end;
}

.frame {
  margin: 0;
  background: #1c1b17;
  overflow: hidden;
}

.chapter-paper .frame {
  background: #d9d0bc;
}

.frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: inset(14% 10% 14% 10%);
  transform: scale(1.04);
  transition:
    clip-path 1.35s cubic-bezier(0.77, 0, 0.18, 1),
    transform 1.5s cubic-bezier(0.77, 0, 0.18, 1);
}

.frame.is-in img {
  clip-path: inset(0);
  transform: scale(1);
}

.frame-portrait {
  aspect-ratio: 4 / 5;
}

.frame-wide {
  aspect-ratio: 16 / 9;
  margin-top: clamp(2.5rem, 6vh, 4.5rem);
}

.frame-band {
  aspect-ratio: 16 / 7;
  margin-top: clamp(2.5rem, 7vh, 5rem);
  margin-left: calc(var(--pad) * -1);
  margin-right: calc(var(--pad) * -1);
  width: calc(100% + (var(--pad) * 2));
}

.frame-fiber {
  aspect-ratio: 4 / 5;
}

.rack-figure {
  margin: 2.5rem 0 0;
  max-width: 16rem;
}

.rack {
  display: grid;
  gap: 5px;
  padding: 10px 12px 12px;
  background: #1a1915;
  border: 1px solid rgba(181, 105, 60, 0.55);
  box-shadow: inset 0 0 0 4px #0d0c0a;
}

.chapter-ink .rack {
  background: #0e0d0b;
}

.u {
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 0 8px;
  background:
    linear-gradient(180deg, rgba(239, 231, 214, 0.08), rgba(239, 231, 214, 0.02));
  border: 1px solid rgba(239, 231, 214, 0.16);
}

.u i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--moss);
  box-shadow: 0 0 6px var(--moss);
  animation: breathe 3.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.22s);
}

.u i:last-child {
  animation-delay: calc(var(--i) * 0.22s + 0.45s);
  opacity: 0.75;
}

.u.warm i {
  background: var(--amber);
  box-shadow: 0 0 7px var(--amber);
}

.rack-figure figcaption,
figcaption {
  margin-top: 0.85rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: rgba(239, 231, 214, 0.62);
}

.copy-narrow {
  max-width: 46rem;
}

.steps {
  list-style: none;
  margin: clamp(2.5rem, 6vh, 4rem) 0 0;
  padding: 0 0 0 2.25rem;
  position: relative;
  max-width: 28rem;
}

.steps::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.35rem;
  bottom: 0.35rem;
  width: 1px;
  background: var(--copper);
  transform: scaleY(0);
  transform-origin: top center;
  transition: transform 1.5s cubic-bezier(0.77, 0, 0.18, 1);
}

.steps.is-drawn::before {
  transform: scaleY(1);
}

.steps li {
  position: relative;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: clamp(2rem, 4vw, 3.15rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  padding: 0.55rem 0;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.steps.is-drawn li {
  opacity: 1;
  transform: none;
}

.steps.is-drawn li:nth-child(1) { transition-delay: 0.15s; }
.steps.is-drawn li:nth-child(2) { transition-delay: 0.32s; }
.steps.is-drawn li:nth-child(3) { transition-delay: 0.49s; }
.steps.is-drawn li:nth-child(4) { transition-delay: 0.66s; }

.steps li::before {
  content: "";
  position: absolute;
  left: -2.45rem;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3px;
  background: var(--ink);
  box-shadow: 0 0 0 4px var(--paper);
}

.fixes-stage {
  position: relative;
  background: #0c0b09;
}

.fixes-stage .treat {
  position: absolute;
  inset: 0;
}

.fixes-stage .treat-trouble {
  filter: sepia(0.55) saturate(1.7) hue-rotate(-8deg) brightness(0.82) contrast(1.05);
  animation: trouble 16s ease-in-out infinite;
}

.fixes-stage .treat-steady {
  filter: saturate(0.78) brightness(1.05) contrast(1.02);
  animation: steady 16s ease-in-out infinite;
}

.contact .copy p {
  font-size: clamp(1.35rem, 2vw, 1.7rem);
}

.mail-line {
  margin: clamp(2rem, 6vh, 4rem) 0 0;
}

.mail {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: clamp(1.85rem, 5.4vw, 5.4rem);
  letter-spacing: -0.035em;
  line-height: 1.02;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--copper);
  overflow-wrap: anywhere;
}

.mail:hover {
  color: var(--copper);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding: 2.5rem var(--pad) 2.75rem;
  background: var(--paper);
  color: var(--ink);
  border-top: 1px solid rgba(18, 17, 14, 0.14);
  font-size: 0.95rem;
  font-weight: 400;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(181, 105, 60, 0.7);
}

@keyframes ken {
  from { transform: scale(1.08); }
  to { transform: scale(1); }
}

@keyframes rise {
  from { transform: translateY(115%); }
  to { transform: translateY(0); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.28; }
  50% { opacity: 1; }
}

@keyframes trouble {
  0%, 38% { opacity: 1; }
  52%, 88% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes steady {
  0%, 38% { opacity: 0; }
  52%, 88% { opacity: 1; }
  100% { opacity: 0; }
}

@media (min-width: 900px) {
  :root {
    --index: 10.5rem;
  }

  .chapter-index {
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
    position: fixed;
    z-index: 55;
    left: 1.6rem;
    top: 50%;
    transform: translateY(-50%);
  }

  .chapter-index a {
    color: var(--chrome);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    opacity: 0.45;
    transition: opacity 0.3s ease, color 0.4s ease;
  }

  .chapter-index a span {
    display: inline-block;
    width: 1.9rem;
    font-family: var(--serif);
    font-optical-sizing: auto;
    font-weight: 500;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
  }

  .chapter-index a[aria-current="true"] {
    opacity: 1;
    color: var(--copper);
  }

  .hero-copy,
  .chapter,
  .site-header,
  .site-footer {
    padding-left: calc(var(--index) + var(--pad));
  }

  .site-header {
    padding-right: var(--pad);
  }

  .sites-layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.82fr);
    align-items: center;
  }

  .sites-layout .frame {
    margin-right: calc(var(--pad) * -1);
  }

  .servers-layout {
    grid-template-columns: minmax(280px, 0.78fr) minmax(320px, 1fr);
    align-items: center;
  }

  .fixes-layout {
    grid-template-columns: minmax(280px, 0.9fr) minmax(280px, 0.72fr);
    align-items: center;
  }

  .frame-band {
    margin-left: calc((var(--index) + var(--pad)) * -1);
    margin-right: calc(var(--pad) * -1);
    width: calc(100% + var(--index) + (var(--pad) * 2));
  }
}

@media (max-width: 899px) {
  h1 {
    font-size: clamp(3.4rem, 16vw, 5.4rem);
  }

  h2 {
    font-size: clamp(3.3rem, 16vw, 5rem);
  }

  .chapter {
    padding-top: 5.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .hero-media img,
  .word,
  .u i,
  .treat-trouble,
  .treat-steady {
    animation: none;
  }

  .hero-media img {
    transform: none;
  }

  .word {
    transform: none;
  }

  .frame img,
  .steps::before,
  .steps li {
    transition: none;
    clip-path: none;
    transform: none;
    opacity: 1;
  }

  .treat-trouble {
    opacity: 0;
  }

  .treat-steady {
    opacity: 1;
  }

  .u i {
    opacity: 0.9;
  }
}
