/* Rabbit Hole Day: an explorer's notebook that fills in as you go. */

:root {
  --paper: #f5f6f2;
  --sheet: #ffffff;
  --tint: #ebede6;
  --tint-2: #e0e3da;
  --pencil: #c3c8bf;
  --ink: #1b2130;
  --ink-2: #4a5263;
  --ink-3: #646b79;
  --accent: #2346c9;
  --accent-2: #1a37a3;
  --on-accent: #ffffff;

  --serif: Literata, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --step-small: 0.9375rem;
  --step-body: 1.125rem;
  --step-lead: clamp(1.25rem, 1.08rem + 0.55vw, 1.5rem);
  --step-head: clamp(1.625rem, 1.2rem + 1.4vw, 2.375rem);
  --step-display: clamp(2.25rem, 1rem + 5.6vw, 6rem);

  --frame: clamp(20px, 5vw, 72px);
  --max: 1240px;
  --rail: 88px;

  --travel: cubic-bezier(0.45, 0, 0.1, 1);
  --arrive: cubic-bezier(0.25, 0.8, 0.25, 1);

  color-scheme: light;
}

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

html {
  background: var(--paper);
  scrollbar-color: var(--pencil) var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Dot-grid notebook paper. */
body {
  margin: 0;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='1' fill='%23d3d8ce'/%3E%3C/svg%3E");
  color: var(--ink);
  font: 400 var(--step-body)/1.6 var(--serif);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
  caret-color: var(--accent);
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-2);
}

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

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

.masthead,
main,
.colophon {
  width: min(100% - 2 * var(--frame), var(--max));
  margin-inline: auto;
}

/* ------------------------------------------------------------ masthead */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 24px;
  padding-top: 28px;
}

.wordmark,
.wordmark:visited,
.wordmark:hover {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font: 600 1.125rem/1.3 var(--serif);
  text-decoration: none;
}

.wordmark svg {
  width: 26px;
  height: 26px;
}

.motto {
  margin: 0;
  color: var(--ink-2);
  font: italic 400 1.0625rem/1.4 var(--serif);
}

/* ------------------------------------------------------------ opening */

.opening {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  align-items: start;
  column-gap: clamp(36px, 6vw, 112px);
  padding: clamp(48px, 8vh, 104px) 0 clamp(24px, 5vh, 56px);
}

.opening h1 {
  grid-column: 1 / -1;
  max-width: 17ch;
  margin: 0 0 clamp(28px, 4.5vh, 48px) -0.04em;
  font-size: var(--step-display);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.opening-text {
  padding-top: 6px;
}

/* A hole without a cover picture: one column, sized for reading. */
.opening:not(.has-cover) {
  grid-template-columns: minmax(0, 1fr);
}

.opening:not(.has-cover) .opening-text {
  max-width: 46rem;
}

.lede {
  max-width: 30ch;
  margin: 0 0 20px;
  font-size: var(--step-lead);
  line-height: 1.4;
}

.opening p {
  max-width: 46ch;
}

.how {
  margin: 0 0 30px;
  color: var(--ink-2);
}

.opening .intro {
  margin: 0 0 14px;
}

.cover {
  margin: 0;
}

.cover img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

figcaption {
  margin-top: 12px;
  color: var(--ink-2);
  font: var(--step-small)/1.5 var(--sans);
}

.credit {
  display: block;
  color: var(--ink-3);
}

.notice {
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px 16px;
  border-radius: 4px;
  background: var(--sheet);
  font: 1rem/1.5 var(--sans);
}

/* ------------------------------------------------------------ buttons */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}

.button,
.button:visited {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 3px;
  background: var(--accent);
  color: var(--on-accent);
  font: 600 1rem/1.2 var(--sans);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.button:hover {
  background: var(--accent-2);
  color: var(--on-accent);
}

.button:active {
  transform: translateY(1px);
}

.button.quiet,
.button.quiet:visited {
  background: var(--tint);
  color: var(--ink);
}

.button.quiet:hover {
  background: var(--tint-2);
  color: var(--ink);
}

.button svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.text-button {
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: 500 var(--step-small)/1.4 var(--sans);
  text-decoration: underline;
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.text-button:hover {
  color: var(--accent-2);
}

.text-button svg {
  width: 17px;
  height: 17px;
  margin-right: 7px;
  vertical-align: -3px;
}

/* ------------------------------------------------------------ the route */

.route {
  padding-top: clamp(64px, 11vh, 140px);
  scroll-margin-top: 24px;
}

.route:focus {
  outline: none;
}

.route-head {
  max-width: 1120px;
  margin: 0 auto clamp(40px, 6vh, 64px);
}

.route-head h2 {
  margin: 0 0 6px;
  font-size: var(--step-head);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

.route-progress {
  margin: 0;
  color: var(--ink-2);
  font: 1rem/1.5 var(--sans);
}

.trail {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
}

/* The pencilled route ahead, and the ink of the route already travelled. */
.pencil,
.ink {
  position: absolute;
  left: 50%;
  top: 0;
  width: 0;
  margin-left: -1px;
  pointer-events: none;
}

.pencil {
  border-left: 2px dotted var(--pencil);
}

.ink {
  height: 0;
  border-left: 2px solid var(--accent);
  transition: height 0.9s var(--travel);
}

.ink.still {
  transition: none;
}

.stops {
  display: grid;
  gap: clamp(32px, 5vh, 52px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.stop {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail) minmax(0, 1fr);
  align-items: start;
  scroll-margin-top: 24px;
}

.node {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  width: 22px;
  height: 22px;
  margin-top: 3px;
  border: 2px solid var(--pencil);
  border-radius: 50%;
  background: var(--paper);
  color: var(--on-accent);
}

.node svg {
  width: 13px;
  height: 13px;
}

/* Entries hug the route; the stop you're on gets a full sheet. */
.entry {
  grid-row: 1;
  width: fit-content;
  max-width: 470px;
}

.entry.sheet {
  width: 100%;
}

.left .entry {
  grid-column: 1;
  justify-self: end;
}

.right .entry {
  grid-column: 3;
  justify-self: start;
}

.entry p {
  margin: 0 0 14px;
}

.entry > :last-child,
.entry .keep > :last-child {
  margin-bottom: 0;
}

.meta {
  margin: 0 0 6px;
  color: var(--ink-2);
  font: var(--step-small)/1.5 var(--sans);
}

.entry-title {
  margin: 0;
  font-size: 1.3125rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.entry-title:focus {
  outline: none;
}

/* stops already visited */

.done .node {
  border-color: var(--accent);
  background: var(--accent);
}

.done .kept {
  margin-top: 8px;
}

.done .thumb {
  width: 132px;
  margin: 14px 0 0;
}

.done .thumb img,
.keep img {
  mix-blend-mode: multiply;
}

.done details {
  margin-top: 10px;
  font: var(--step-small)/1.5 var(--sans);
}

.done summary {
  width: max-content;
  color: var(--accent);
  cursor: pointer;
}

.done details ul {
  margin: 10px 0 0;
  padding-left: 1.1em;
}

.done details li + li {
  margin-top: 8px;
}

/* the stop you're on */

.current .node {
  width: 26px;
  height: 26px;
  margin-top: 30px;
  border: 4px solid var(--accent);
  background: var(--sheet);
}

.current .entry {
  max-width: 540px;
}

.sheet {
  padding: clamp(24px, 2.6vw, 36px);
  border-radius: 4px;
  background: var(--sheet);
}

.current .entry-title {
  margin: 4px 0 16px;
  font-size: var(--step-head);
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.try strong,
.welcome strong {
  font-weight: 600;
}

.current .actions {
  margin-top: 26px;
}

.keep {
  margin-top: 26px;
}

.keep-label {
  margin: 0 0 6px !important;
  color: var(--ink-2);
  font: 600 var(--step-small)/1.4 var(--sans);
}

.keep-text {
  margin: 0 !important;
  font-size: var(--step-lead);
  line-height: 1.38;
  text-wrap: pretty;
}

.keep figure {
  max-width: 300px;
  margin: 20px 0 0;
}

.deeper {
  margin-top: 34px;
  font: var(--step-small)/1.55 var(--sans);
}

.deeper ul {
  margin: 8px 0 0;
  padding-left: 1.1em;
}

.deeper li + li {
  margin-top: 10px;
}

.deeper .note {
  display: block;
  color: var(--ink-2);
}

/* stops still ahead */

.ahead .meta {
  margin: 0;
  color: var(--ink-3);
}

.peek .entry-title a {
  color: var(--ink);
}

.peek .meta {
  margin-bottom: 8px;
}

.peek p {
  color: var(--ink-2);
}

/* the bottom */

.bottom {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}

.bottom .node {
  grid-column: 1;
}

.bottom .entry {
  grid-column: 1;
  grid-row: 2;
  justify-self: center;
  max-width: 760px;
  margin-top: 18px;
}

.bottom.ahead .entry {
  text-align: center;
}

.bottom.done .node {
  width: 26px;
  height: 26px;
}

.ending h3 {
  margin: 0 0 14px;
  font-size: var(--step-head);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.ending h3:focus {
  outline: none;
}

.ending-line {
  font-size: var(--step-lead);
  line-height: 1.38;
}

.ending h4 {
  margin: 34px 0 14px;
  font: 600 var(--step-small)/1.4 var(--sans);
  color: var(--ink-2);
}

.kept-list {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kept-list li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 12px;
}

.kept-list svg {
  width: 18px;
  height: 18px;
  margin-top: 5px;
  color: var(--accent);
}

.kept-list p {
  margin: 0;
}

.kept-from {
  display: block;
  color: var(--ink-2);
  font: var(--step-small)/1.5 var(--sans);
}

.ending .actions {
  margin-top: 32px;
}

.status {
  min-height: 1.5em;
  margin: 14px 0 0 !important;
  color: var(--ink-2);
  font: var(--step-small)/1.5 var(--sans);
}

.route-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 28px;
  margin: 48px 0 0;
}

/* ------------------------------------------------------------ more holes */

.more {
  max-width: 1120px;
  margin: 0 auto;
  padding-top: clamp(96px, 14vh, 160px);
}

.more-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 28px;
}

.more h2 {
  margin: 0 0 6px;
  font-size: var(--step-head);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

.more-note {
  margin: 0;
  color: var(--ink-2);
  font: 1rem/1.5 var(--sans);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The whole card is the link: the title's link stretches over it. */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 4px;
  background: var(--sheet);
  box-shadow: 0 0 0 1px rgba(27, 33, 48, 0.06);
  transition: box-shadow 0.2s ease, transform 0.2s var(--arrive);
}

.card:hover {
  box-shadow: 0 0 0 1px rgba(27, 33, 48, 0.08), 0 10px 28px -12px rgba(27, 33, 48, 0.28);
}

.card:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.card-pic {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--tint);
}

.card-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge {
  position: absolute;
  left: 10px;
  top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--sheet);
  color: var(--ink);
  font: 600 0.8125rem/1.5 var(--sans);
}

.done-badge {
  background: var(--accent);
  color: var(--on-accent);
}

.badge svg {
  width: 13px;
  height: 13px;
}

.card-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 16px 18px 18px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1.1875rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.card h3 a {
  color: var(--ink);
  text-decoration: none;
}

.card h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card h3 a:focus-visible {
  outline: none;
}

.card:hover h3 a {
  color: var(--accent);
}

.card-teaser {
  margin: 0 0 14px;
  color: var(--ink-2);
  font: var(--step-small)/1.5 var(--sans);
}

.card-meta {
  margin: auto 0 0;
  color: var(--ink-3);
  font: 0.875rem/1.4 var(--sans);
}

/* ------------------------------------------------------------ colophon */

.colophon {
  margin-top: clamp(112px, 18vh, 220px);
  padding-bottom: 56px;
}

.sendoff {
  max-width: 20ch;
  margin: 0 0 40px -0.04em;
  font-size: clamp(1.875rem, 0.9rem + 4.6vw, 5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.colophon-notes {
  display: grid;
  gap: 8px;
  color: var(--ink-2);
  font: var(--step-small)/1.6 var(--sans);
}

.colophon-notes p {
  max-width: 72ch;
  margin: 0;
}

.colophon-notes .maker {
  margin-bottom: 8px;
  color: var(--ink);
  font: var(--step-body)/1.5 var(--serif);
}

.credits {
  margin-top: 8px;
}

.credits summary {
  width: max-content;
  color: var(--accent);
  cursor: pointer;
}

.credits summary span {
  color: var(--ink-3);
}

.credits-label {
  margin: 18px 0 6px !important;
  color: var(--ink-2);
  font-weight: 600;
}

.credits-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  line-height: 1.5;
  columns: 2 22rem;
  column-gap: 32px;
}

.credits-list li {
  margin-bottom: 4px;
  break-inside: avoid;
}

.credits-list a {
  color: var(--ink-2);
}

.credits-list a:hover {
  color: var(--accent);
}

/* ------------------------------------------------------------ 404 */

.lost {
  padding: clamp(80px, 16vh, 180px) 0;
}

.lost h1 {
  max-width: 14ch;
  margin: 0 0 20px -0.04em;
  font-size: var(--step-display);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
}

.lost p {
  margin: 0 0 12px;
}

/* ------------------------------------------------------------ small screens */

@media (max-width: 860px) {
  .opening {
    grid-template-columns: minmax(0, 1fr);
  }

  .cover {
    max-width: 560px;
  }
}

@media (max-width: 560px) {
  .cards {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  /* On phones a card is a row: a small square picture beside the words. */
  .card {
    flex-direction: row;
  }

  .card-pic {
    flex: none;
    width: 104px;
    aspect-ratio: auto;
  }

  .card-pic img {
    position: absolute;
    inset: 0;
  }

  .badge {
    left: 6px;
    top: 6px;
    padding: 1px 8px;
    font-size: 0.75rem;
  }

  .card-text {
    padding: 12px 14px 14px;
  }

  .card h3 {
    margin-bottom: 4px;
    font-size: 1.0625rem;
  }

  .card-teaser {
    margin-bottom: 8px;
    font-size: 0.875rem;
  }

  .card-meta {
    font-size: 0.8125rem;
  }
}

@media (max-width: 760px) {
  .stop {
    grid-template-columns: 34px minmax(0, 1fr);
    column-gap: 10px;
  }

  .sheet {
    padding: 22px 18px;
  }

  .node,
  .bottom .node {
    grid-column: 1;
  }

  .left .entry,
  .right .entry,
  .bottom .entry {
    grid-column: 2;
    grid-row: 1;
    justify-self: stretch;
    max-width: none;
    margin-top: 0;
  }

  .bottom {
    grid-template-columns: 34px minmax(0, 1fr);
    justify-items: stretch;
  }

  .bottom .node {
    justify-self: center;
  }

  .bottom.ahead .entry {
    text-align: left;
  }

  .pencil,
  .ink {
    left: 17px;
  }

  .current .node {
    margin-top: 26px;
  }

  .route-tools {
    justify-content: flex-start;
    padding-left: 46px;
  }
}

/* ------------------------------------------------------------ motion */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .arriving .entry {
    animation: arrive 0.8s var(--arrive) 0.3s both;
  }

  .returned .keep {
    animation: arrive 0.7s var(--arrive) both;
  }

  .card:hover {
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ink {
    transition: none;
  }
}

@keyframes arrive {
  from {
    opacity: 0.35;
    transform: translateY(10px);
  }
}

/* ------------------------------------------------------------ utilities */

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: 3px;
  background: var(--accent);
  color: var(--on-accent);
  font: 600 1rem/1.3 var(--sans);
  text-decoration: none;
}

.skip:focus {
  top: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
