/*
  Fealty design system. Monochrome, editorial, architectural.
  Display: Cormorant Garamond. Reading: Inter. Labels and figures: IBM Plex Mono.
  The Portcullis Shield is the only image. Everything else is type, space and hairlines.
*/
:root {
  --black: #080808;
  --charcoal: #141414;
  --graphite: #202020;
  --bone: #f0eee9;
  --ivory: #d7d3ca;
  --steel: #777777;

  --display: "Cormorant Garamond", "Cormorant", Garamond, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --gutter: clamp(20px, 5vw, 72px);
  --page: 1440px;
  --chapter-space: clamp(112px, 17vw, 224px);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --press: 160ms;

  color-scheme: dark;
}

/* ---------- Fonts (self-hosted; the CSP allows fonts from this site only) ---------- */

@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/cormorant-garamond-latin-300-normal.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/cormorant-garamond-latin-300-italic.woff2") format("woff2");
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/cormorant-garamond-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--black);
}

body {
  margin: 0;
  background: var(--black);
  color: var(--bone);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Film grain over everything, tinted bone so the black stays warm. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.94 0 0 0 0 0.93 0 0 0 0 0.91 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1,
h2,
p,
ol,
ul,
dl,
dd {
  margin: 0;
  padding: 0;
}

ol,
ul {
  list-style: none;
}

h1,
h2 {
  font-family: var(--display);
  font-weight: 300;
  text-wrap: balance;
}

em {
  font-style: italic;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a,
button {
  touch-action: manipulation;
}

::selection {
  background: var(--bone);
  color: var(--black);
}

:focus-visible {
  outline: 1px solid var(--bone);
  outline-offset: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.preview-band {
  padding: 8px var(--gutter);
  background: var(--bone);
  color: var(--black);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}

.preview-band:not([hidden]) {
  height: 34px;
  padding-block: 0;
  line-height: 34px;
}

/* ---------- Shared pieces ---------- */

/* The insignia: the shield plus the wordmark, in tight spaced capitals. */
.insignia {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

.insignia img {
  width: 18px;
  height: auto;
}

/* Chapter labels: a Roman numeral, a hairline, then the name. */
.label {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: clamp(28px, 4vw, 48px);
  color: var(--steel);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.label span {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--bone);
}

.label span::after {
  content: "";
  width: clamp(32px, 6vw, 72px);
  height: 1px;
  background: var(--steel);
}

h2 {
  font-size: clamp(3rem, 10vw, 7.25rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.body {
  max-width: 34em;
  margin-top: 24px;
  color: var(--ivory);
  font-size: 17px;
  line-height: 1.6;
}

.aside {
  margin-top: 40px;
  color: var(--steel);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* The portcullis, seen edge-on: a band of bars between movements of the page. */
.bars {
  height: clamp(56px, 9vw, 96px);
  margin-inline: var(--gutter);
  background: repeating-linear-gradient(90deg, var(--graphite) 0 1px, transparent 1px clamp(18px, 2.4vw, 28px));
  -webkit-mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
  mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
}

/* ---------- The Portcullis Shield, drawn inline so its gate can move ---------- */

.portcullis {
  position: absolute;
  z-index: 0;
  height: auto;
  pointer-events: none;
}

.portcullis .shield-outer,
.portcullis .shield-inner {
  fill: none;
  stroke: var(--bone);
  vector-effect: non-scaling-stroke;
}

.portcullis .shield-outer {
  stroke-width: 1.5;
}

.portcullis .shield-inner {
  stroke-width: 1;
  stroke-opacity: 0.4;
}

.portcullis .gate {
  fill: var(--ivory);
}

.portcullis .rivets {
  fill: var(--black);
}

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

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(32px, 1fr) auto auto auto auto;
  min-height: 100vh;
  min-height: 100svh;
  max-width: var(--page);
  margin-inline: auto;
  padding: max(18px, env(safe-area-inset-top)) var(--gutter) max(28px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.preview-band:not([hidden]) ~ main .hero {
  min-height: calc(100svh - 34px);
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  grid-row: 1;
}

.topbar-note {
  color: var(--steel);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

/* On a phone the shield stands behind the headline, cut by the right edge. */
.portcullis-hero {
  top: 11svh;
  right: -34vw;
  width: 92vw;
  max-width: 560px;
  opacity: 0.16;
}

.hero-title {
  position: relative;
  z-index: 1;
  grid-row: 3;
  font-size: min(23vw, 12.5svh);
  line-height: 0.86;
  letter-spacing: -0.035em;
}

.hero-title .line {
  display: block;
  /* Room for the italic overhang and the ascenders, so the mask doesn't cut letters. */
  padding: 0.08em 0.12em 0.04em 0;
  margin: -0.08em 0 -0.04em;
  overflow: hidden;
}

.hero-title .line > * {
  display: block;
}

.hero-title .line:nth-child(2) {
  padding-left: 0.5em;
}

.hero-lede {
  position: relative;
  z-index: 1;
  grid-row: 4;
  max-width: 26em;
  margin-top: clamp(20px, 3.5svh, 32px);
  color: var(--ivory);
  font-size: 17px;
  line-height: 1.5;
}

.hero-form,
.hero > .thanks {
  position: relative;
  z-index: 1;
  grid-row: 5;
  margin-top: clamp(20px, 3.5svh, 32px);
}

.hero-note {
  position: relative;
  z-index: 1;
  grid-row: 6;
  margin-top: 20px;
  color: var(--steel);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ---------- Signup form ---------- */

.signup {
  display: grid;
  gap: 10px;
  max-width: 460px;
}

.signup input[type="email"] {
  width: 100%;
  height: 56px;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px solid var(--steel);
  border-radius: 0;
  background: transparent;
  color: var(--bone);
  font-family: var(--sans);
  font-size: 17px; /* 16px or more stops iOS zooming in on focus */
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 200ms ease;
}

.signup input[type="email"]::placeholder {
  color: var(--steel);
  opacity: 1;
}

.signup input[type="email"]:focus {
  outline: none;
  border-bottom-color: var(--bone);
}

.signup input[aria-invalid="true"] {
  border-bottom-color: var(--bone);
}

.signup button {
  height: 56px;
  margin-top: 6px;
  border: 0;
  border-radius: 0;
  background: var(--bone);
  color: var(--black);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--press) var(--ease-out), background-color 200ms ease, opacity 200ms ease;
}

.signup button:active {
  transform: scale(0.97);
}

.signup button:disabled {
  opacity: 0.55;
  cursor: default;
}

@media (hover: hover) and (pointer: fine) {
  .signup button:not(:disabled):hover {
    background: var(--ivory);
  }
}

/* Hidden from people. Bots that fill it are ignored. */
.trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.signup-error {
  color: var(--bone);
  font-size: 14px;
}

.signup-error::before {
  content: "— ";
  color: var(--steel);
}

.signup-privacy {
  color: var(--steel);
  font-size: 13px;
}

/* Thank-you state, which replaces the form. */
.thanks {
  position: relative;
  z-index: 1;
  animation: settle 700ms var(--ease-out) both;
}

.thanks-line {
  font-family: var(--display);
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-style: italic;
  font-weight: 300;
  line-height: 1;
}

.thanks-detail {
  margin-top: 12px;
  color: var(--ivory);
  font-size: 15px;
}

/* ---------- Chapters ---------- */

.chapter {
  position: relative;
  max-width: var(--page);
  margin-inline: auto;
  padding: var(--chapter-space) var(--gutter) 0;
}

/* I. The principle */
.principle-title {
  max-width: 9ch;
  font-size: clamp(4rem, 17vw, 14rem);
  line-height: 0.86;
  letter-spacing: -0.04em;
}

.principle-sub {
  margin-top: clamp(40px, 7vw, 96px);
  color: var(--ivory);
  font-family: var(--display);
  font-size: clamp(2rem, 6vw, 4.25rem);
  font-weight: 300;
  line-height: 1;
  text-align: right;
}

/* II. Gym Lockdown */
.steps {
  margin-top: 56px;
  border-bottom: 1px solid var(--graphite);
}

.steps li {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: baseline;
  padding: 28px 0;
  border-top: 1px solid var(--graphite);
}

.step-no {
  color: var(--steel);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
}

.steps p {
  font-family: var(--display);
  font-size: clamp(1.625rem, 3.2vw, 2.5rem);
  font-weight: 300;
  line-height: 1.12;
}

/* III. The Tribunal: the record of rulings. */
.record {
  margin-top: 64px;
  border-bottom: 1px solid var(--graphite);
}

.case {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "no stamp"
    "excuse excuse"
    "ruling ruling";
  align-items: center;
  row-gap: 14px;
  padding: 32px 0 36px;
  border-top: 1px solid var(--graphite);
}

.case-no {
  grid-area: no;
  color: var(--steel);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.excuse {
  grid-area: excuse;
  color: var(--ivory);
  font-family: var(--mono);
  font-size: 14px;
}

.ruling {
  grid-area: ruling;
  font-family: var(--display);
  font-size: clamp(2.25rem, 6.5vw, 4.25rem);
  font-style: italic;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.stamp {
  grid-area: stamp;
  justify-self: end;
  padding: 5px 10px 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  user-select: none;
  -webkit-user-select: none;
}

.stamp-denied {
  background: var(--bone);
  color: var(--black);
}

.stamp-granted {
  outline: 1px solid var(--ivory);
  outline-offset: -1px;
  color: var(--bone);
}

/* IV. Your Score */
.score-figure {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--display);
  font-weight: 300;
  line-height: 0.74;
  user-select: none;
  -webkit-user-select: none;
}

.score-num {
  font-size: clamp(16rem, 72vw, 38rem);
  letter-spacing: -0.06em;
}

.score-of {
  color: var(--steel);
  font-family: var(--mono);
  font-size: clamp(1.25rem, 3vw, 2rem);
}

.score-copy {
  margin-top: 48px;
}

/* V. No traps */
.exit h2 {
  max-width: 11ch;
}

/* VI. Price */
.price {
  max-width: 880px;
  border-bottom: 1px solid var(--graphite);
}

.price div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0;
  border-top: 1px solid var(--graphite);
}

.price dt {
  font-family: var(--display);
  font-size: clamp(2.25rem, 6vw, 4rem);
  font-style: italic;
  font-weight: 300;
  line-height: 1;
}

.price dd {
  font-family: var(--mono);
  font-size: clamp(1.125rem, 2.4vw, 1.5rem);
  letter-spacing: 0.04em;
}

/* VII. The gate */
.gate-chapter {
  padding-bottom: var(--chapter-space);
  overflow: hidden;
}

.portcullis-gate {
  top: 22%;
  right: -38vw;
  width: 96vw;
  max-width: 720px;
  opacity: 0.14;
}

.gate-copy {
  position: relative;
  z-index: 1;
}

.gate-title {
  max-width: 10ch;
}

.gate-title em {
  display: block;
}

.gate-copy .signup {
  margin-top: 40px;
}

/* ---------- Footer ---------- */

.footer {
  max-width: var(--page);
  margin-inline: auto;
  padding: 0 var(--gutter) max(28px, env(safe-area-inset-bottom));
}

.footer-line {
  padding: 72px 0 56px;
  border-top: 1px solid var(--graphite);
  color: var(--ivory);
  font-family: var(--display);
  font-size: clamp(2.25rem, 7vw, 5rem);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.015em;
}

.footer-base {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 32px;
}

.footer-links {
  display: flex;
  gap: 28px;
}

.footer-links a {
  padding: 10px 0;
  color: var(--steel);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 200ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .footer-links a:hover {
    color: var(--bone);
  }
}

/* ---------- Privacy, terms and support ---------- */

.page {
  max-width: calc(760px + var(--gutter) * 2);
  min-height: 70vh;
  margin-inline: auto;
  padding: max(24px, env(safe-area-inset-top)) var(--gutter) 112px;
}

.page .wordmark {
  margin-bottom: clamp(72px, 12vw, 128px);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.page .wordmark a {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.page .wordmark a::before {
  content: "";
  width: 18px;
  height: 21px;
  background: url("art/mark.svg") center / contain no-repeat;
}

.page h1 {
  font-size: clamp(3.25rem, 11vw, 6rem);
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.page h2 {
  margin-top: 64px;
  font-size: clamp(1.875rem, 5vw, 2.5rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.page .body {
  max-width: none;
  margin-top: 16px;
  font-size: 16.5px;
}

.page .updated {
  margin-top: 20px;
  color: var(--steel);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page .legal-list {
  margin-top: 16px;
  padding-left: 20px;
  list-style: square;
  color: var(--ivory);
  font-size: 16.5px;
}

.page .legal-list li + li {
  margin-top: 10px;
}

.page .legal-list li::marker {
  color: var(--steel);
}

.page mark.todo {
  background: var(--bone);
  color: var(--black);
  padding: 0 4px;
}

.page + .footer .footer-base {
  padding-top: 28px;
  border-top: 1px solid var(--graphite);
}

/* ---------- Wider screens: the asymmetric editorial grid ---------- */

@media (min-width: 760px) {
  .principle-sub {
    margin-left: 45%;
    text-align: left;
  }

  .case {
    grid-template-columns: minmax(150px, 3fr) 7fr auto;
    grid-template-areas: "no ruling stamp" "excuse ruling stamp";
    column-gap: 32px;
    row-gap: 10px;
  }

  .exit {
    padding-left: calc(var(--gutter) + 33%);
  }
}

@media (min-width: 1000px) {
  .hero {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: auto minmax(40px, 1fr) auto minmax(40px, 0.5fr) auto;
    column-gap: 24px;
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }

  .topbar {
    grid-column: 1 / -1;
  }

  .hero-title {
    grid-column: 1 / 9;
    font-size: min(14vw, 22svh);
  }

  /* The shield stands whole beside the statement. */
  .portcullis-hero {
    top: 13svh;
    right: var(--gutter);
    width: auto;
    height: 62svh;
    max-width: none;
    opacity: 1;
  }

  .hero-lede {
    grid-column: 1 / 5;
    grid-row: 5;
    align-self: end;
    margin-top: 0;
  }

  .hero-form,
  .hero > .thanks {
    grid-column: 6 / 10;
    grid-row: 5;
    margin-top: 0;
  }

  .hero-note {
    grid-column: 10 / 13;
    grid-row: 5;
    align-self: end;
    margin-top: 0;
    text-align: right;
  }

  .chapter-head {
    max-width: 760px;
  }

  .lockdown {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 24px;
    align-items: start;
  }

  .lockdown .chapter-head {
    grid-column: 1 / 6;
    position: sticky;
    top: 18vh;
  }

  .lockdown .steps,
  .lockdown .aside {
    grid-column: 7 / 13;
  }

  .lockdown .steps {
    margin-top: 12px;
  }

  .score {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 24px;
    align-items: end;
  }

  .score .label {
    grid-column: 1 / -1;
  }

  .score-figure {
    grid-column: 1 / 7;
  }

  .score-copy {
    grid-column: 7 / 13;
    margin-top: 0;
    padding-bottom: 4%;
  }

  .price-chapter .price {
    margin-left: 25%;
  }

  .price-chapter .aside {
    margin-left: 25%;
  }

  /* The monument: far larger than the hero's shield, and cut by the edge of the page. */
  .portcullis-gate {
    top: 10%;
    right: -14vw;
    width: auto;
    height: 118%;
    max-width: none;
    opacity: 1;
  }

  .gate-copy {
    max-width: min(44%, 600px);
  }
}

/* ---------- Motion ---------- */
/*
  1. The gate lowers once when the page opens (rare, so it may take its time).
  2. When someone joins, the gate beside that form rises: "Be first through the gate."
  3. Chapters arrive once as they scroll in. The forms never animate in; they work at once.
*/

@keyframes gate-lower {
  from {
    transform: translateY(-96px);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes gate-raise {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-96px);
  }
}

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

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .portcullis-hero .gate {
    animation: gate-lower 1400ms var(--ease-in-out) 250ms both;
  }

  .hero-title .line > * {
    animation: rise 1100ms var(--ease-out) both;
  }

  .hero-title .line:nth-child(1) > * {
    animation-delay: 120ms;
  }

  .hero-title .line:nth-child(2) > * {
    animation-delay: 200ms;
  }

  .hero-title .line:nth-child(3) > * {
    animation-delay: 280ms;
  }

  .hero-lede,
  .hero-note,
  .topbar {
    animation: fade 900ms ease 500ms both;
  }

  .portcullis[data-gate].is-open .gate {
    animation: gate-raise 1600ms var(--ease-in-out) both;
  }

  /* Hidden only once motion.js has run, so the page never depends on it. */
  .motion [data-reveal] {
    opacity: 0;
    transform: translateY(28px);
    transition:
      opacity 900ms var(--ease-out),
      transform 1100ms var(--ease-out);
  }

  .motion [data-reveal].is-in {
    opacity: 1;
    transform: none;
  }
}

/* Reduced motion: no movement. Fades stay, because they explain what changed. */
@media (prefers-reduced-motion: reduce) {
  .thanks {
    animation: fade 300ms ease both;
  }

  .signup button,
  .signup button:active {
    transition: none;
    transform: none;
  }

  .portcullis[data-gate] .gate {
    transition: opacity 600ms ease;
  }

  .portcullis[data-gate].is-open .gate {
    opacity: 0;
  }
}

@media (prefers-reduced-transparency: reduce) {
  body::after {
    display: none;
  }
}
