/* The train journey story with the pass punched at every station. Colours in :root (the Playground palette). The
   stage sticks while the section scrolls by; the post is one card, the window on the left (a strip on top on the
   phone), the diary and the rail pass on the right. The pass is two halves of paper with a half notch each, so the
   seam between them reads as one perforation; its shadow is a drop-shadow on the wrapper because the paper is masked. */
:root {
  --page: #ece6db;          /* the page behind the post */
  --card: #fbf9f5;          /* the post card (and what shows through a punched hole) */
  --ink: #1d1a16;           /* the words */
  --muted: #8d857a;         /* the small words */
  --ticket: #f5eedf;        /* the paper of the rail pass */
  --ticket-ink: #2a2520;    /* the print of the pass */
  --accent: #c63d2f;        /* rail red: the line, the train, the punch ring */
}

* { box-sizing: border-box; }

html { touch-action: manipulation; }

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.trip { position: relative; height: 400vh; }

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2.4vh, 28px) clamp(10px, 3vw, 28px);
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 18% 0%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(90% 70% at 100% 100%, rgba(198, 61, 47, 0.07), transparent 65%),
    var(--page);
}

@supports (height: 100lvh) {
  .stage { height: 100lvh; }
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .35 0 0 0 0 .3 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* the post card */
.post {
  position: relative;
  width: min(100%, 980px);
  height: min(100%, 540px);
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
  gap: clamp(14px, 3vh, 30px);
  padding: clamp(10px, 2.4vh, 22px);
  border-radius: clamp(18px, 3vh, 26px);
  background: linear-gradient(180deg, #fffdfa, var(--card));
  box-shadow:
    0 1px 1px rgba(60, 45, 30, 0.05),
    0 6px 14px -6px rgba(60, 45, 30, 0.12),
    0 30px 60px -28px rgba(60, 45, 30, 0.32),
    0 60px 120px -60px rgba(60, 45, 30, 0.25);
}

.post__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(60, 45, 30, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* the window: the photo is wider than the glass and slides as the train goes */
.window {
  position: relative;
  margin: 0;
  min-height: 0;
  border-radius: clamp(14px, 2.6vh, 22px);
  padding: 5px;
  background: linear-gradient(180deg, #ece5d9, #ddd4c5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), inset 0 -1px 0 rgba(60, 45, 30, 0.08), 0 1px 2px rgba(60, 45, 30, 0.08);
}

.window__glass {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: clamp(10px, 2.2vh, 18px);
  background: #9fb3a4;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.window__view {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 165%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 45%;
  display: block;
  user-select: none;
}

/* a soft reflection on the glass and its inner shadow */
.window__shine {
  position: absolute;
  inset: -20% -40%;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.22) 46%, rgba(255, 255, 255, 0.06) 52%, transparent 60%);
}

.window__glass::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 10px 24px -10px rgba(0, 0, 0, 0.35), inset 0 -18px 30px -18px rgba(0, 0, 0, 0.3);
}

.window__cap {
  position: absolute;
  left: clamp(10px, 2vh, 16px);
  bottom: clamp(10px, 2vh, 16px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  background: rgba(20, 18, 15, 0.32);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.window__cap svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; }

/* the right column */
.body {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.6vh, 14px);
  padding: clamp(0px, 1vh, 8px) clamp(0px, 1vw, 10px) 0 0;
}

.blog {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(10.5px, 1.7vh, 12px);
}

.blog__mark {
  display: grid;
  place-items: center;
  width: clamp(20px, 3.6vh, 26px);
  height: clamp(20px, 3.6vh, 26px);
  border-radius: 8px;
  background: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
}

.blog__mark svg { width: 60%; height: 60%; fill: none; stroke: #f5eedf; stroke-width: 1.6; stroke-linecap: round; }

.blog__name { font-weight: 650; font-stretch: 108%; letter-spacing: -0.01em; }

.blog__meta { margin-left: auto; color: var(--muted); }

.title {
  margin: 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-weight: 420;
  font-variation-settings: 'opsz' 96, 'SOFT' 50;
  font-size: clamp(19px, min(4.6vw, 6vh), 44px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

/* the diary of the day */
.entry {
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.7vh, 6px);
  min-height: 0;
}

.entry > * { margin: 0; }

.entry__kick {
  font-size: clamp(10.5px, 1.7vh, 12px);
  font-weight: 560;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.entry__head {
  font-size: clamp(13px, min(4.4vw, 2.5vh), 19px);
  font-weight: 620;
  letter-spacing: -0.012em;
  line-height: 1.2;
}

.entry__text {
  font-size: clamp(11.5px, min(3.6vw, 1.95vh), 14.5px);
  line-height: 1.45;
  color: #5d564d;
  max-width: 46ch;
}

/* the rail pass */
.pass {
  margin-top: auto;
  position: relative;
  filter: drop-shadow(0 1px 1px rgba(60, 45, 30, 0.12)) drop-shadow(0 10px 14px rgba(60, 45, 30, 0.14));
  cursor: default;
}

.pass__paper {
  position: relative;
  border-radius: 12px;
  color: var(--ticket-ink);
  --notch: 6px;
  --seam: clamp(44px, 9vh, 58px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 30%),
    var(--ticket);
  /* two half notches where the stub meets the legs */
  -webkit-mask:
    radial-gradient(circle var(--notch) at 0 var(--seam), #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle var(--notch) at 100% var(--seam), #0000 97%, #000) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle var(--notch) at 0 var(--seam), #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle var(--notch) at 100% var(--seam), #0000 97%, #000) right / 51% 100% no-repeat;
}

.pass__paper::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(80, 60, 30, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.pass__grain {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0.35;
  mix-blend-mode: multiply;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .45 0 0 0 0 .3 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
}

.pass__top {
  position: relative;
  height: calc(var(--seam) - clamp(16px, 3.2vh, 22px));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding: 0 clamp(10px, 2vh, 16px) 2px;
  font-size: clamp(9.5px, 1.6vh, 11px);
}

.pass__brand {
  font-weight: 700;
  font-stretch: 118%;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.92em;
}

.pass__valid { color: #8a7f6c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* the line of the journey with the little train */
.line {
  position: relative;
  height: clamp(16px, 3.2vh, 22px);
  margin: 0 clamp(10px, 2vh, 16px);
  --p: 0;
  --t: 0;
}

.line__base,
.line__fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 1.5px;
  margin-top: -0.75px;
  border-radius: 2px;
}

.line__base { right: 0; background: repeating-linear-gradient(90deg, rgba(80, 60, 30, 0.28) 0 3px, transparent 3px 6px); }

.line__fill { width: calc(var(--p) * 100%); background: var(--accent); }

.line__tick {
  position: absolute;
  top: 50%;
  left: calc(var(--at) * 100%);
  width: 1.5px;
  height: 7px;
  margin: -3.5px 0 0 -0.75px;
  border-radius: 1px;
  background: rgba(80, 60, 30, 0.4);
}

.line__train {
  position: absolute;
  top: 50%;
  left: calc(var(--t) * 100%);
  width: 0;
  height: 0;
}

.line__train i {
  position: absolute;
  left: calc(var(--t) * -20px);
  top: -4.5px;
  width: 20px;
  height: 9px;
  border-radius: 5px 7px 7px 5px;
  background:
    linear-gradient(90deg, transparent 3px, rgba(255, 255, 255, 0.85) 3px 6px, transparent 6px 8px, rgba(255, 255, 255, 0.85) 8px 11px, transparent 11px) 0 2.5px / 100% 2px no-repeat,
    linear-gradient(180deg, #d9503f, var(--accent));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 2px 4px -1px rgba(120, 30, 20, 0.5);
}

/* the four legs, below the perforation */
.legs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: 0 clamp(4px, 1vh, 8px) clamp(4px, 1vh, 8px);
  list-style: none;
}

.legs::before {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  top: 0;
  border-top: 1.5px dashed rgba(80, 60, 30, 0.22);
}

.leg {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: clamp(7px, 1.6vh, 12px) clamp(5px, 1vw, 10px) clamp(4px, 1vh, 8px);
  color: #b0a691;
  transition: color 0.45s ease;
}

.leg + .leg::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 6px;
  border-left: 1px solid rgba(80, 60, 30, 0.12);
}

.leg.is-done { color: var(--ticket-ink); }

.leg__day { font-size: clamp(9px, 1.5vh, 10.5px); font-weight: 500; opacity: 0.8; }

.leg__route {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: clamp(10px, min(2.9vw, 2vh), 14px);
  font-weight: 680;
  font-stretch: 104%;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.leg__route svg { width: 0.8em; height: 0.6em; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; flex: none; }

.leg__km { font-size: clamp(9.5px, 1.6vh, 11.5px); font-variant-numeric: tabular-nums; }

/* the punch: a red ring that draws, a hole that bites through, a disc of paper that drops */
.punch {
  position: absolute;
  top: clamp(5px, 1.2vh, 9px);
  right: clamp(4px, 0.8vw, 8px);
  width: clamp(15px, 3vh, 20px);
  height: clamp(15px, 3vh, 20px);
  pointer-events: none;
}

.punch__ring { position: absolute; inset: -3px; width: calc(100% + 6px); height: calc(100% + 6px); overflow: visible; }

.punch__ring circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.punch__hole {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: inset 0 1.5px 2px rgba(60, 40, 20, 0.45), inset 0 -1px 0 rgba(255, 255, 255, 0.6), 0 0.5px 0 rgba(255, 255, 255, 0.8);
  transform: scale(0);
}

/* the disc of paper lives on the pass wrapper, outside the masked paper, so it can fall past its edge */
.chad {
  position: absolute;
  z-index: 3;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fffaf0, var(--ticket) 60%, #e6dcc6);
  box-shadow: 0 1px 2px rgba(60, 40, 20, 0.3), inset 0 0 0 0.5px rgba(80, 60, 30, 0.22);
}

/* the tally under the pass */
.tally {
  display: flex;
  gap: clamp(14px, 3vw, 28px);
  padding-top: clamp(6px, 1.4vh, 12px);
  border-top: 1px solid rgba(60, 45, 30, 0.08);
}

.tally__item { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.tally__item--end { margin-left: auto; text-align: right; }

.tally small { font-size: clamp(9.5px, 1.5vh, 11px); color: var(--muted); }

.tally b {
  font-size: clamp(12px, 2.2vh, 16px);
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

@media (hover: hover) {
  .pass:hover .pass__paper { background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 34%), var(--ticket); }
  .leg { cursor: pointer; }
  .leg:hover { color: var(--ticket-ink); }
}

/* the phone: the window becomes a strip on top */
@media (max-width: 640px) {
  .post {
    grid-template-columns: minmax(0, 1fr);
    height: min(100%, 600px);
    grid-template-rows: clamp(48px, 14vh, 140px) minmax(0, 1fr);
    gap: clamp(8px, 1.8vh, 14px);
  }
  .window { padding: 3px; }
  .window__cap { font-size: 10px; padding: 3px 8px 3px 6px; left: 8px; bottom: 6px; }
  .blog__meta { display: none; }
  .tally { gap: 14px; }
}

@media (max-width: 640px) and (max-height: 460px) {
  .window__cap { display: none; }
  .entry__text { -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
}
