/* Intentional Tech Labs: a surveyor's field book.
   Printed layer: Newsreader. Hand-written layer: Kalam, in ink or red pencil. */

:root {
  --paper: #ECE3B3;
  --paper-light: #F3ECC8;
  --grid: rgba(54, 110, 98, 0.16);
  --ink: #1C2A4A;
  --graphite: #4A4A44;
  --red: #C21F1F;
  --olive: #34402C;
  --olive-deep: #273021;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --hand: "Kalam", "Segoe Print", "Bradley Hand", cursive;

  --wrap: 72rem;
  --gutter: clamp(1.1rem, 4vw, 2.5rem);
  --space: clamp(4.5rem, 10vw, 8rem);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: 500; line-height: 1.08; letter-spacing: -0.012em; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; }

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

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

.hand { font-family: var(--hand); font-weight: 400; letter-spacing: 0; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 10;
  background: var(--ink); color: var(--paper); padding: .6rem 1rem; text-decoration: none;
}
.skip:focus { top: 1rem; }

/* Buttons */
.button {
  display: inline-block;
  font: 600 1.05rem/1 var(--serif);
  color: var(--paper-light);
  background: var(--ink);
  border: 0;
  border-radius: 3px;
  padding: 1rem 1.5rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease;
}
.button:hover { background: var(--red); }
.button[disabled] { opacity: .65; cursor: progress; }

/* Masthead */
.masthead {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-block: 1.5rem;
}
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.brand-mark {
  font-size: 2.1rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1;
  padding: .2rem .5rem .3rem;
  border: 2px solid var(--ink);
  border-radius: 2px;
}
.brand-name { font-size: .95rem; line-height: 1.15; color: var(--graphite); }
.masthead-cta { font-size: 1rem; text-underline-offset: .25em; text-decoration-thickness: 1px; }
.masthead-cta:hover { color: var(--red); }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(2.5rem, 6vw, 5rem);
  align-items: center;
  padding-block: clamp(2.5rem, 7vw, 5.5rem) var(--space);
}
.hero h1 { font-size: clamp(2.3rem, 4.6vw, 3.9rem); font-weight: 500; }
.lede { margin-top: 1.6rem; max-width: 34rem; font-size: 1.2rem; color: var(--graphite); line-height: 1.65; }
.hero-actions { margin-top: 2.2rem; display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.4rem; }
.hand-aside { color: var(--red); font-size: 1.2rem; transform: rotate(-2deg); }

/* The field book page */
.logbook {
  position: relative;
  margin: 0;
  padding: 1.4rem 1.5rem 1.2rem 3.4rem;
  background-color: var(--paper-light);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 1.25rem 1.25rem;
  background-position: -1px -1px;
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(39, 48, 33, .12), 0 22px 40px -24px rgba(39, 48, 33, .45);
  transform: rotate(-.7deg);
}
.logbook::before { /* red margin rule */
  content: ""; position: absolute; top: 0; bottom: 0; left: 2.35rem;
  width: 2px; background: rgba(194, 31, 31, .55);
}
.log-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  padding-bottom: .55rem; margin-bottom: .4rem;
  border-bottom: 1.5px solid var(--ink);
  font-size: .9rem; color: var(--graphite);
}
.log-head .hand { color: var(--ink); font-size: 1.15rem; }

.log { list-style: none; margin: 0; padding: 0; }
.entry:nth-child(1) { --i: 0; } .entry:nth-child(2) { --i: 1; } .entry:nth-child(3) { --i: 2; }
.entry:nth-child(4) { --i: 3; } .entry:nth-child(5) { --i: 4; } .log-total { --i: 5; }
.entry {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 9.5rem;
  gap: .9rem 1.5rem;
  align-items: start;
  padding-block: .7rem;
  border-bottom: 1px dashed rgba(28, 42, 74, .22);
}
.entry time { font-size: .85rem; color: var(--graphite); padding-top: .25rem; font-variant-numeric: tabular-nums; }
.ink {
  position: relative;
  font-family: var(--hand);
  font-size: 1.08rem;
  line-height: 1.4;
  color: var(--ink);
}
.note {
  font-family: var(--hand);
  font-size: .98rem;
  line-height: 1.25;
  color: var(--red);
  padding-top: .15rem;
  transform: rotate(-1.5deg);
}
.entry:not(.is-marked) .note { color: var(--graphite); }

.ring {
  position: absolute; top: -1.15rem; left: -1.25rem;
  width: calc(100% + 2.45rem); height: calc(100% + 2.2rem);
  overflow: visible; pointer-events: none;
}
.ring path {
  fill: none; stroke: var(--red); stroke-width: .7; stroke-linecap: round; stroke-linejoin: round; opacity: .8;
}

.log-total {
  margin-top: .9rem;
  color: var(--red);
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: .3em;
  transform: rotate(-1deg);
  transform-origin: left;
}
.log-caption { margin-top: .9rem; font-size: .85rem; color: var(--graphite); font-style: italic; }

/* The one orchestrated moment: the log writes itself, then gets marked up. */
@media (prefers-reduced-motion: no-preference) {
  .entry .ink {
    clip-path: inset(-2rem 100% -2rem -2rem);
    animation: write .6s cubic-bezier(.4, .1, .5, 1) forwards;
    animation-delay: calc(.35s + var(--i) * .45s);
  }
  .entry .note, .log-total {
    opacity: 0;
    animation: mark .35s ease-out forwards;
    animation-delay: calc(2.9s + var(--i) * .3s);
  }
  .ring path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw .55s ease-in-out forwards;
    animation-delay: calc(2.75s + var(--i) * .3s);
  }
}
@keyframes write { to { clip-path: inset(-2rem -2rem -2rem -2rem); } }
@keyframes mark { to { opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Sections */
.process, .ledger-section, .why { padding-block: 0 var(--space); }
.process h2, .ledger-section h2, .why h2 { font-size: clamp(1.9rem, 3.4vw, 2.7rem); }

.steps {
  list-style: none; margin: 2.6rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2rem;
}
.steps li { border-top: 1.5px solid var(--ink); padding-top: 1.1rem; }
.step-num {
  display: inline-grid; place-items: center;
  width: 2.3rem; height: 2.3rem;
  font: 700 1.3rem/1 var(--hand); color: var(--red);
  border: 1.8px solid var(--red); border-radius: 50% 46% 52% 48%;
  transform: rotate(-6deg);
}
.steps h3 { margin-top: .9rem; font-size: 1.4rem; }
.steps p { margin-top: .55rem; font-size: 1.02rem; color: var(--graphite); }
.steps del { text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.steps ins { text-decoration: none; color: var(--red); font-size: 1.12rem; white-space: nowrap; }

/* Ledger */
.ledger-section {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}
.ledger-intro p { margin-top: 1rem; color: var(--graphite); max-width: 24rem; }
.ledger-scroll { overflow-x: auto; }
.ledger {
  width: 100%; min-width: 30rem;
  border-collapse: collapse;
  background: var(--paper-light);
  font-size: 1.02rem;
}
.ledger th {
  text-align: left; font-weight: 600; font-size: .95rem;
  padding: .9rem 1.1rem; border-bottom: 3px double var(--ink);
}
.ledger td { padding: .95rem 1.1rem; vertical-align: top; border-bottom: 1px solid rgba(54, 110, 98, .3); }
.ledger td:first-child { color: var(--graphite); width: 45%; }
.ledger th:first-child, .ledger td:first-child { border-right: 3px double rgba(194, 31, 31, .6); }
.ledger tbody tr:last-child td { border-bottom: 0; }

/* Why */
.why { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: clamp(2rem, 5vw, 4rem); }
.why-text { font-size: clamp(1.3rem, 2.2vw, 1.65rem); line-height: 1.5; max-width: 40rem; }

/* Contact */
.visit { background: var(--olive); color: var(--paper); padding-block: var(--space); scroll-margin-top: 0; }
.visit-inner {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: clamp(2rem, 6vw, 5rem); align-items: start;
}
.visit-copy h2 { font-size: clamp(2rem, 3.6vw, 2.9rem); }
.visit-copy > p { margin-top: 1rem; color: rgba(236, 227, 179, .85); max-width: 26rem; }
.next-steps { margin: 2rem 0 0; padding-left: 1.3rem; color: rgba(236, 227, 179, .85); }
.next-steps li { padding-left: .3rem; margin-bottom: .4rem; }
.next-steps li::marker { font-family: var(--hand); color: var(--paper); }

.sheet {
  background-color: var(--paper-light);
  color: var(--ink);
  padding: clamp(1.4rem, 3.5vw, 2.4rem);
  border-radius: 2px;
  box-shadow: 0 24px 50px -30px rgba(0, 0, 0, .6);
}
.field + .field-row, .field-row + .trap, .field-row + .turnstile, .field-row + .submit-row { margin-top: 1.4rem; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem; }
.field label { display: block; font-weight: 600; font-size: 1rem; margin-bottom: .45rem; }
.optional { font-weight: 400; color: var(--graphite); }

.sheet textarea, .sheet input {
  width: 100%;
  font-family: var(--hand);
  font-size: 1.15rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  border-radius: 0;
  padding: .35rem .1rem;
}
.sheet textarea {
  resize: vertical;
  min-height: 11rem;
  line-height: 2rem;
  padding-top: .15rem;
  background-image: linear-gradient(transparent calc(2rem - 1px), rgba(54, 110, 98, .35) calc(2rem - 1px));
  background-size: 100% 2rem;
  background-attachment: local;
}
.sheet textarea::placeholder, .sheet input::placeholder { color: rgba(74, 74, 68, .55); }
.sheet textarea:focus-visible, .sheet input:focus-visible { outline: none; border-bottom-color: var(--red); box-shadow: 0 2px 0 var(--red); }
.sheet [aria-invalid="true"] { border-bottom-color: var(--red); }

.hint { margin-top: .4rem; font-size: .9rem; color: var(--graphite); }
.error { margin-top: .35rem; font-size: .95rem; color: var(--red); min-height: 0; }
.error:empty { display: none; }

.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.turnstile:empty { display: none; }
.turnstile { margin-top: 1.4rem; }

.submit-row { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.4rem; margin-top: 1.8rem; }
.form-status { font-size: 1rem; color: var(--graphite); }
.form-status.is-error { color: var(--red); }

.sheet-done { grid-column: 2; }
.sheet-done:focus { outline: none; }
.done-title { font-size: 2.4rem; color: var(--red); line-height: 1.1; margin-bottom: .6rem; }

/* Footer */
.footer { background: var(--olive-deep); color: rgba(236, 227, 179, .75); font-size: .95rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem 2rem; padding-block: 2rem; }
.footer strong { color: var(--paper); }

/* Narrow screens */
@media (max-width: 62rem) {
  .hero, .ledger-section, .why, .visit-inner { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.4rem 2rem; }
  .sheet-done { grid-column: 1; }
  .logbook { transform: rotate(-.4deg); }
}
@media (max-width: 40rem) {
  body { font-size: 1.0625rem; }
  .brand-name { display: none; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .logbook { padding: 1.1rem 1rem 1rem 2.6rem; }
  .logbook::before { left: 1.7rem; }
  .entry { grid-template-columns: minmax(0, 1fr); gap: .9rem; }
  .ring { top: -.6rem; left: -.6rem; width: calc(100% + 1.2rem); height: calc(100% + 1.2rem); }
  .ledger { min-width: 0; }
  .ledger thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ledger tr { display: block; border-bottom: 1px solid rgba(54, 110, 98, .3); padding: .9rem 1rem; }
  .ledger td { display: block; padding: 0; border: 0; width: auto; }
  .ledger td:first-child { width: auto; border-right: 0; font-size: .95rem; }
  .ledger td:last-child { margin-top: .35rem; padding-left: .8rem; border-left: 3px double rgba(194, 31, 31, .6); }
  .ledger tbody tr:last-child { border-bottom: 0; }
  .entry time { padding-top: 0; }
  .note { padding-left: .2rem; }
  .button { width: 100%; text-align: center; }
  .masthead .masthead-cta { font-size: .95rem; }
}
