/* Every Brick Has a Tale to Tell, v09: a collector's binder on a desk. */
:root {
  --desk: #e8e2d4;
  --desk-d: #d9d1bf;
  --paper: #f6f4ee;
  --paper-d: #ebe7dc;
  --ink: #1f3a8a;
  --pencil: #7a7a7a;
  --print: #3b3b3b;
  --binder: #b5523b;
  --binder-d: #8a3a29;
  --manila: #d8cbb0;
  --manila-d: #c8b892;
  --rule: #c3cddd;
  --pen: "Nothing You Could Do", "Bradley Hand", "Segoe Print", cursive;
  --type: "Courier Prime", "Courier New", Courier, monospace;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .27 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { overflow-x: clip; }
body {
  margin: 0;
  overflow-x: clip;
  min-height: 100vh;
  font-family: var(--type);
  font-size: 16px;
  line-height: 1.45;
  color: var(--print);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 60%),
    var(--noise),
    linear-gradient(180deg, var(--desk), var(--desk-d));
  background-attachment: fixed, scroll, fixed;
}

.pen { font-family: var(--pen); color: var(--ink); font-weight: 400; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* Header: a typed label stuck to the desk */
.top { padding: 18px 16px 0; display: flex; justify-content: center; }
.home {
  display: inline-block;
  font-family: var(--type);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--print);
  text-decoration: none;
  background: var(--paper);
  padding: 7px 14px 6px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08), 0 6px 14px -8px rgba(60, 40, 20, .45);
  transform: rotate(-1.2deg);
  position: relative;
}
.home::before, .home::after {
  content: "";
  position: absolute;
  top: -7px;
  width: 34px;
  height: 14px;
  background: rgba(240, 236, 220, .78);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .04);
}
.home::before { left: -12px; transform: rotate(-24deg); }
.home::after { right: -12px; transform: rotate(18deg); }
.home:hover { color: var(--ink); }

.desk { padding: 20px 16px 40px; overflow-x: clip; }

/* ---------- Binder, shared ---------- */
.binder {
  position: relative;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "cover" "tabs" "mech" "stack";
  max-width: 560px;
}

.cover {
  grid-area: cover;
  position: relative;
  background: var(--noise), linear-gradient(160deg, #ddd1b8, var(--manila) 55%, #cfc09f);
  border: 12px solid var(--binder);
  border-bottom-width: 0;
  border-radius: 8px 8px 0 0;
  padding: 22px 18px 26px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), inset 0 18px 30px -24px rgba(0, 0, 0, .5);
}
.cover-label {
  background: var(--paper);
  padding: 18px 18px 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
  transform: rotate(-.6deg);
  border-top: 6px solid #d9c9a1;
}
.cover-title {
  margin: 0;
  font-size: clamp(36px, 9.5vw, 54px);
  line-height: 1.12;
  letter-spacing: .01em;
}
.cover-tag {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.4;
  color: var(--print);
}
.cover-lede { margin: 26px 4px 0; }
.cover-h {
  margin: 0 0 6px;
  font-family: var(--type);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--print);
  display: inline-block;
  border-bottom: 2px solid rgba(31, 58, 138, .55);
  padding-bottom: 2px;
}
.cover-text { margin: 10px 0 0; font-size: 25px; line-height: 1.45; }
.cover-slip {
  margin: 26px 0 0;
  font-size: 16px;
  line-height: 1.45;
  background: rgba(246, 244, 238, .82);
  padding: 12px 14px;
  transform: rotate(.5deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
  max-width: 34em;
}

/* Tabs (phone: a strip of divider tabs above the sheets) */
.tabs {
  grid-area: tabs;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 5px 4px;
  background: var(--binder);
  padding: 10px 12px 0;
}
.tabs-label {
  width: 100%;
  font-size: 13px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #f3e5dc;
  margin: 0 0 2px 2px;
}
.tab {
  font-family: var(--type);
  font-size: 15px;
  line-height: 1;
  padding: 9px 10px 8px;
  border: 0;
  border-radius: 7px 7px 0 0;
  color: var(--print);
  cursor: pointer;
  background: var(--tc, #e9dcc0);
  box-shadow: inset 0 -3px 4px -3px rgba(0, 0, 0, .25);
}
.tab[aria-current="true"] { background: var(--paper); font-weight: 700; box-shadow: none; }
.tab:hover { filter: brightness(1.04); }

/* Lever arch mechanism (phone: a bar across the top of the stack) */
.mech {
  grid-area: mech;
  position: relative;
  height: 30px;
  background: var(--binder);
  pointer-events: none;
  z-index: 5;
}
.plate {
  position: absolute;
  left: 18px; right: 18px; top: 9px; height: 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #f1f1ef, #a9aaa8 45%, #d7d8d6 60%, #8d8e8c);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .35);
}
.ring {
  position: absolute;
  top: 2px;
  width: 16px; height: 52px;
  border-radius: 8px;
  background: linear-gradient(90deg, #8e8f8d, #f4f4f2 40%, #b9bab8 70%, #7d7e7c);
  box-shadow: 0 3px 4px rgba(0, 0, 0, .35);
}
.r1 { left: calc(20px + (100% - 40px) * .3 - 8px); }
.r2 { left: calc(20px + (100% - 40px) * .7 - 8px); }
.lever {
  position: absolute;
  right: 26px; top: 4px;
  width: 54px; height: 9px;
  border-radius: 5px;
  background: linear-gradient(180deg, #e9e9e7, #8f908e);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .3);
}

/* The stack: every sheet and the back pocket share one grid cell */
.stack {
  grid-area: stack;
  position: relative;
  z-index: 1;
  display: grid;
  background: var(--manila);
  border: 12px solid var(--binder);
  border-top-width: 0;
  border-radius: 0 0 8px 8px;
  padding: 0 8px 10px;
  perspective: 2600px;
  perspective-origin: 50% 0%;
  touch-action: pan-y;
  box-shadow: 0 30px 40px -30px rgba(60, 40, 20, .6);
}

.sheet, .pocket { grid-area: 1 / 1; }

.sheet {
  position: relative;
  display: grid;
  transform-style: preserve-3d;
  transform-origin: 50% 0%;
  transition: transform .72s cubic-bezier(.42, .02, .24, 1), opacity .2s ease 0s;
  will-change: transform;
}
.sheet.turned { transform: rotateX(180deg); opacity: 0; transition: transform .72s cubic-bezier(.42, .02, .24, 1), opacity .25s ease .36s; }
.face {
  grid-area: 1 / 1;
  position: relative;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--noise), var(--paper);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .12), 0 2px 0 -1px var(--paper-d), 0 3px 2px -1px rgba(0, 0, 0, .1);
}
.back { transform: rotateX(180deg); overflow: hidden; }
.front { padding: 56px 18px 22px; }

/* Punched holes with ring reinforcers */
.holes { position: absolute; inset: 0; pointer-events: none; }
.holes i {
  position: absolute;
  top: 14px;
  width: 22px; height: 22px;
  margin-left: -11px;
  border-radius: 50%;
  background: radial-gradient(circle, #b9ab88 0 4.5px, #fbfaf6 5.5px 9px, rgba(0, 0, 0, .08) 9.5px, rgba(0, 0, 0, 0) 11px);
}
.holes i:nth-child(1) { left: 30%; }
.holes i:nth-child(2) { left: 70%; }

/* Record form */
.form-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border-bottom: 2px solid var(--print);
  padding-bottom: 6px;
}
.form-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .2em;
  text-transform: uppercase;
}
.form-no { font-size: 14px; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.form-no .pen { font-size: 24px; letter-spacing: 0; margin-left: 4px; text-transform: none; }

.fields { margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 6.3em minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  border-bottom: 1px solid var(--rule);
  padding: 7px 0 5px;
  min-height: 40px;
}
.row dt {
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6a6a6a;
}
.row dd { margin: 0; font-family: var(--pen); color: var(--ink); font-size: 20px; line-height: 1.32; }
.row dd.pencil { color: #6d6d6d; font-size: 19px; }

.section-h {
  margin: 18px 0 0;
  font-family: var(--type);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  background: #e7e3d6;
  padding: 6px 8px 5px;
  color: var(--print);
}

.drawing { margin: 16px 0 0; border: 1px solid #9a9a9a; padding: 6px 8px 4px; background: rgba(255, 255, 255, .35); }
.drawing figcaption { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: #6a6a6a; }
.drawing svg { display: block; width: 100%; height: auto; overflow: visible; }

.notes { margin: 16px 0 0; }
.notes-h {
  margin: 0;
  font-family: var(--type);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6a6a6a;
}
.notes-h.strong { font-weight: 700; color: var(--print); }
.notes p {
  margin: 2px 0 0;
  font-family: var(--pen);
  color: var(--ink);
  font-size: 19px;
  line-height: 30px;
  background-image: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0) 0 29px, var(--rule) 29px 30px);
  background-position: 0 6px;
}

/* Pencil drawings draw themselves */
.p { fill: none; stroke: #6c6c6c; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.1s ease var(--d, 0s); }
.p.soft { stroke: #9a9a9a; stroke-width: 1; }
.p.dash { stroke-dasharray: 4 5; stroke-dashoffset: 0; opacity: 0; transition: opacity .6s ease var(--d, 0s); }
.dt { fill: #6a6a6a; opacity: 0; transition: opacity .8s ease var(--d, 0s); font-family: var(--type); }
.dt.hand { font-family: var(--pen); }
.dt.out { fill: none; stroke: #5f5f5f; stroke-width: 1.1; }
.dt.groove { fill: none; stroke: #b9b3a6; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.drawn .p { stroke-dashoffset: 0; }
.drawn .p.dash, .drawn .dt { opacity: 1; }

/* Back of a turned sheet: faint show-through */
.back .ghost {
  position: absolute;
  left: 50%; top: 40%;
  transform: translate(-50%, -50%) scaleX(-1);
  font-family: var(--pen);
  font-size: 34px;
  color: var(--ink);
  opacity: .07;
  white-space: nowrap;
}

/* Clear sleeve with the photograph */
.sleeve .front { background: linear-gradient(115deg, rgba(255, 255, 255, .0) 30%, rgba(255, 255, 255, .55) 42%, rgba(255, 255, 255, 0) 52%), linear-gradient(180deg, #e7eaee, #dde2e8); }
.sleeve-strip {
  position: absolute;
  left: 0; right: 0; top: 0; height: 44px;
  background: rgba(255, 255, 255, .7);
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.sleeve-card {
  margin: 8px auto 0;
  background: #fff;
  padding: 10px 10px 34px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
  transform: rotate(-1.4deg);
  max-width: 520px;
}
.sleeve-card img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
.sleeve-gloss {
  position: absolute;
  inset: 44px 0 0;
  pointer-events: none;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 0 38%, rgba(255, 255, 255, .32) 46%, rgba(255, 255, 255, 0) 56%);
}

/* Back pocket and order slip */
.pocket {
  position: relative;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--noise), linear-gradient(180deg, #dccfb4, var(--manila));
  overflow: hidden;
}
.slip {
  position: relative;
  margin: 26px 16px 0;
  background: var(--noise), var(--paper);
  padding: 18px 18px 130px;
  transform: rotate(-1.8deg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.slip-head { margin: 0; font-weight: 700; font-size: 14px; letter-spacing: .22em; text-transform: uppercase; border-bottom: 2px solid var(--print); padding-bottom: 6px; }
.slip-name { margin: 10px 0 0; font-size: 16px; }
.slip-details { list-style: none; margin: 10px 0 0; padding: 0; }
.slip-details li { position: relative; padding: 5px 0 5px 30px; border-bottom: 1px dotted #b8b3a6; font-size: 16px; }
.slip-details li::before {
  content: "";
  position: absolute; left: 2px; top: 8px;
  width: 15px; height: 15px;
  border: 1.5px solid var(--print);
}
.slip-details li::after {
  content: "";
  position: absolute; left: 6px; top: 6px;
  width: 7px; height: 13px;
  border: solid var(--ink);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(40deg);
}
.slip-price { margin: 16px 0 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; }
.slip-price .pen { font-size: 46px; line-height: 1; }
.slip-ed { font-size: 16px; }
.buy {
  margin-top: 14px;
  font-family: var(--type);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--binder-d);
  background: transparent;
  border: 2.5px solid var(--binder-d);
  border-radius: 3px;
  padding: 11px 16px 10px;
  cursor: pointer;
  transform: rotate(1deg);
}
.buy:hover { background: rgba(181, 82, 59, .08); }
.buy.done { color: #6d6d6d; border-color: #9a9a9a; }
.slip-status { margin: 10px 0 0; min-height: 30px; font-size: 24px; }
.pocket-front {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 110px;
  background: var(--noise), linear-gradient(180deg, #cdbb94, #c3b088);
  border-top: 1px solid rgba(255, 255, 255, .35);
  clip-path: polygon(0 18%, 50% 0, 100% 18%, 100% 100%, 0 100%);
  box-shadow: 0 -2px 0 rgba(0, 0, 0, .05);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pocket-front span { font-size: 13px; letter-spacing: .3em; text-transform: uppercase; color: rgba(60, 45, 20, .55); margin-top: 18px; }

/* Turn controls */
.turnbar {
  max-width: 560px;
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}
.turn {
  font-family: var(--type);
  font-size: 15px;
  color: var(--print);
  background: var(--paper);
  border: 1px solid #b9b2a2;
  padding: 10px 10px 9px;
  cursor: pointer;
  box-shadow: 0 2px 0 #cfc7b5;
}
.turn:disabled { opacity: .45; cursor: default; }
#prev { justify-self: start; }
#next { justify-self: end; }
.where { margin: 0; font-size: 15px; text-align: center; letter-spacing: .06em; }

.nextch { text-align: center; margin: 34px 0 0; }
.nextch a {
  display: inline-block;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
  padding: 10px 22px 12px;
  box-shadow: 0 6px 14px -8px rgba(60, 40, 20, .45);
  transform: rotate(.8deg);
}
.nextch small { display: block; font-family: var(--type); font-size: 13px; letter-spacing: .2em; text-transform: uppercase; color: var(--print); }
.nextch span { display: block; font-family: var(--pen); font-size: 28px; line-height: 1.3; }
.nextch a:hover span { text-decoration: underline; }

/* ---------- Desktop: the binder lies open ---------- */
@media (min-width: 1020px) {
  .top { justify-content: flex-start; padding: 22px 36px 0; }
  .desk { padding-top: 14px; }
  .binder {
    max-width: none;
    width: min(1160px, calc(100vw - 210px));
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "cover stack";
    background: linear-gradient(90deg, var(--binder-d), var(--binder) 6%, var(--binder) 94%, var(--binder-d));
    padding: 14px;
    border-radius: 10px;
    box-shadow: 0 40px 50px -34px rgba(60, 35, 15, .7), inset 0 0 0 1px rgba(0, 0, 0, .15);
  }
  .cover {
    display: flex;
    flex-direction: column;
    border: 0;
    border-radius: 3px 0 0 3px;
    padding: 34px 40px 30px 34px;
    box-shadow: inset -26px 0 30px -26px rgba(0, 0, 0, .45);
  }
  .cover-title { font-size: clamp(40px, 3.6vw, 54px); }
  .cover-text { font-size: 26px; }
  .cover-slip { font-size: 14px; margin: auto 0 0; transform: translateY(-4px) rotate(.5deg); }
  .cover-lede { margin-bottom: 26px; }
  .cover-lede { margin-top: 30px; }

  .stack {
    border: 0;
    border-radius: 0 3px 3px 0;
    padding: 0;
    perspective: 2800px;
    perspective-origin: 0% 50%;
    box-shadow: inset 26px 0 30px -26px rgba(0, 0, 0, .4);
  }
  .sheet, .sheet.turned { transform-origin: 0% 50%; margin: 8px 8px 8px 0; transition: transform .78s cubic-bezier(.42, .02, .24, 1); }
  .sheet.turned { transform: rotateY(-180deg); opacity: 1; }
  .drawing svg { max-height: 170px; }
  .notes p { font-size: 18px; line-height: 27px; background-image: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0) 0 26px, var(--rule) 26px 27px); }
  .back { transform: rotateY(180deg); }
  .front { padding: 26px 28px 22px 64px; }
  .face { border-radius: 0 2px 2px 0; }
  .back { border-radius: 2px 0 0 2px; }
  .holes i { top: auto; left: 30px !important; margin: -11px 0 0 -11px; }
  .holes i:nth-child(1) { top: 36%; }
  .holes i:nth-child(2) { top: 64%; }
  .back .holes i { left: auto !important; right: 30px; margin: -11px -11px 0 0; }
  .sheet.current { cursor: grab; }
  .sheet.current .front::after {
    content: "";
    position: absolute;
    right: 0; bottom: 0;
    width: 34px; height: 34px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0) 50%, #e2ddd0 50%, #f2efe7 70%, #d6d0c1);
    box-shadow: -2px -2px 4px rgba(0, 0, 0, .08);
  }
  body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }
  .sleeve-strip { left: 0; right: auto; top: 0; bottom: 0; width: 50px; height: auto; border-bottom: 0; border-right: 1px solid rgba(0, 0, 0, .06); }
  .sleeve-gloss { inset: 0 0 0 50px; }
  .sleeve .front { display: flex; align-items: center; }
  .sleeve-card { margin: 0 auto; }
  .pocket { min-height: 0; border-radius: 0 3px 3px 0; }
  .slip { margin: 30px 34px 0 46px; }
  .pocket-front { height: 30%; }

  .mech {
    grid-area: auto;
    position: absolute;
    top: 0; bottom: 0;
    left: 50%;
    width: 0;
    height: auto;
    background: none;
  }
  .plate { left: -9px; right: auto; top: 22%; bottom: 22%; width: 18px; height: auto; background: linear-gradient(90deg, #8d8e8c, #f1f1ef 40%, #a9aaa8 70%, #d7d8d6); }
  .ring { width: 70px; height: 18px; top: auto; left: -35px !important; border-radius: 9px; background: linear-gradient(180deg, #8e8f8d, #f4f4f2 40%, #b9bab8 70%, #7d7e7c); }
  .r1 { top: calc(36% - 9px); }
  .r2 { top: calc(64% - 9px); }
  .lever { right: auto; left: -5px; top: calc(22% - 50px); width: 10px; height: 64px; background: linear-gradient(90deg, #e9e9e7, #8f908e); }

  .tabs {
    position: absolute;
    top: 46px;
    left: 100%;
    margin-left: -6px;
    width: 104px;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 6px;
    background: none;
    padding: 0;
  }
  .tabs-label { display: none; }
  .tab {
    text-align: left;
    padding: 10px 12px 9px 18px;
    border-radius: 0 8px 8px 0;
    box-shadow: inset 4px 0 5px -4px rgba(0, 0, 0, .35), 2px 2px 3px rgba(0, 0, 0, .12);
    transition: transform .2s ease;
  }
  .tab[aria-current="true"] { transform: translateX(8px); box-shadow: 2px 2px 4px rgba(0, 0, 0, .16); }

  .turnbar { width: min(1160px, calc(100vw - 210px)); max-width: none; }
  .nextch { margin-top: 26px; }
}

@media (max-width: 1019px) {
  .row { grid-template-columns: 5.8em minmax(0, 1fr); }
  .row dt { letter-spacing: .1em; }
  .dt.hand { font-size: 20px; }
  .dt:not(.hand):not(.out) { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet.turned { transition: none !important; }
  .p { transition: none; stroke-dashoffset: 0; }
  .p.dash, .dt { transition: none; opacity: 1; }
  .tab { transition: none; }
}
