/* ==========================================================================
   The Ledger — honest accounting. A bound ledger, one folio of columnar
   paper with the weak points entered as debits and credits, and an errata
   slip tipped in after it.
   ========================================================================== */

.ledger {
  /* columnar ledger paper */
  --lp: #e6ede0;
  --lp-2: #dce5d5;
  --lp-rule: rgba(84, 142, 114, 0.34);
  --lp-vert: rgba(84, 142, 114, 0.5);
  --lp-red: #bf4a3f;
  --lp-ink: #15231d;
  --lp-ink-2: #3a4d44;
  --lp-ink-3: #5a6b62;
  --line: 28px;

  /* stamp inks, each dark enough to read on the paper */
  --ink-blue: #2a4a8a;
  --ink-violet: #5a3d8a;
  --ink-amber: #8a5208;
  --ink-red: #b3342b;
}

/* ---------- head: the ledger's cover ---------- */
.lg-head {
  padding-top: calc(var(--head) + clamp(3rem, 7vw, 6rem));
  padding-bottom: clamp(3.5rem, 7vw, 6rem);
  background: radial-gradient(60% 70% at 75% 45%, #11282a 0%, var(--night) 70%);
  overflow: hidden;
}
.lg-head-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 3rem clamp(2rem, 6vw, 6rem);
  align-items: center;
}
.lg-kicker { color: var(--signal); }
.lg-title { font-size: var(--t-xxl); font-weight: 200; margin-top: 1.25rem; }
.lg-deck { color: var(--mist); margin-top: 1.5rem; max-width: 30rem; }
.lg-rule-note { margin-top: 2rem; max-width: 30rem; color: var(--haze); font-size: var(--t-s); padding-top: 1.25rem; border-top: 1px solid rgba(143, 195, 198, 0.16); }

.cover {
  position: relative;
  width: min(100%, 21rem);
  aspect-ratio: 5 / 6.6;
  justify-self: center;
  transform: rotate(-4deg);
  filter: drop-shadow(0 40px 36px rgba(0, 0, 0, 0.6));
}
.cover-board {
  position: absolute;
  inset: 0 0 0 1.9rem;
  border-radius: 1px 6px 6px 1px;
  overflow: hidden;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 3px),
    linear-gradient(160deg, #24473a 0%, #183429 55%, #11271f 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset -6px 0 12px -6px rgba(0, 0, 0, 0.6);
}
.cover-spine {
  position: absolute;
  inset: 0 auto 0 0;
  width: 2.6rem;
  border-radius: 4px 0 0 4px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent 30%, rgba(0, 0, 0, 0.3) 85%, rgba(0, 0, 0, 0.5)),
    linear-gradient(180deg, #5a2c22, #43201a);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.cover-spine::before, .cover-spine::after {
  /* raised bands across the spine */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.35));
}
.cover-spine::before { top: 16%; }
.cover-spine::after { bottom: 16%; }
.cover-corner { position: absolute; right: 0; width: 26%; aspect-ratio: 1; background: linear-gradient(135deg, #5a2c22, #3c1c16); }
.cover-corner--t { top: 0; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.cover-corner--b { bottom: 0; clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.cover-label {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%);
  width: 66%;
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  padding: 1.1rem 0.8rem 1rem;
  background: #ece3c8;
  color: #2c2317;
  text-align: center;
  border: 1px solid #6b5a3e;
  outline: 3px double #6b5a3e;
  outline-offset: -7px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.cover-l1 { font-family: var(--f-display); font-weight: 400; font-size: 1.9rem; line-height: 1; letter-spacing: 0.18em; text-transform: uppercase; padding-left: 0.18em; }
.cover-rule { width: 40%; height: 1px; background: #6b5a3e; }
.cover-l2 { font-family: var(--f-text); font-style: italic; font-size: 0.8rem; line-height: 1.25; }
.cover-l3 { font-family: var(--f-mono); font-size: 0.5625rem; letter-spacing: 0.1em; text-transform: uppercase; color: #5b4c34; }
@media (max-width: 52rem) {
  .lg-head-grid { grid-template-columns: minmax(0, 1fr); }
  .cover { width: min(64%, 15rem); justify-self: start; margin-left: 1.5rem; transform: rotate(-3deg); }
}

/* ---------- the folio ---------- */
.book { background: linear-gradient(180deg, var(--night), #08161d); padding-block: clamp(2rem, 5vw, 4rem) clamp(5rem, 10vw, 8rem); }
.folio {
  position: relative;
  background: linear-gradient(180deg, var(--lp) 0%, var(--lp-2) 100%);
  color: var(--lp-ink);
  padding: clamp(2rem, 4vw, 3.25rem) clamp(1rem, 3vw, 2.75rem) clamp(2rem, 4vw, 3rem);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 50px 80px -40px rgba(0, 0, 0, 0.75);
}
.folio::before {
  /* the binding edge */
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 14px;
  background: linear-gradient(90deg, rgba(20, 40, 30, 0.22), transparent);
}
.folio-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--lp-ink);
}
.folio-k { display: block; font-family: var(--f-mono); font-size: var(--t-xxs); font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--lp-ink-3); }
.folio-acct { font-style: italic; }
.folio-no { text-align: right; font-family: var(--f-mono); font-size: 1.1rem; }
.folio-title { font-family: var(--f-display); font-weight: 300; font-size: var(--t-l); line-height: 1; text-align: center; }
.folio-key { margin-top: 0.9rem; font-style: italic; font-size: var(--t-s); color: var(--lp-ink-2); text-align: center; }

/* The table is ruled every 28px; every line of text in it is 28px tall, so the writing sits on the rules. */
.folio-cols, .entry {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.45fr) minmax(0, 12rem);
}
.folio-cols {
  margin-top: 1.6rem;
  height: calc(var(--line) * 2);
  align-items: end;
  font-family: var(--f-mono);
  font-size: var(--t-xxs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: var(--line);
  color: var(--lp-ink-2);
  box-shadow: inset 0 -1px 0 var(--lp-ink), inset 0 -4px 0 var(--lp), inset 0 -5px 0 var(--lp-ink);
}
.folio-cols span { padding: 0 0.9rem 6px; height: 100%; display: flex; align-items: flex-end; }
.folio-cols span:first-child { padding-inline: 0; justify-content: center; }
.entries {
  background: repeating-linear-gradient(180deg, transparent 0 calc(var(--line) - 1px), var(--lp-rule) calc(var(--line) - 1px) var(--line));
}
.entry { box-shadow: inset 0 -1px 0 rgba(21, 35, 29, 0.35); }
.entry > * { padding: 0 0.9rem var(--line); line-height: var(--line); }
.folio-cols span + span, .entry > * + * { border-left: 1px solid var(--lp-vert); }
.folio-cols span:nth-child(2), .entry > .e-item { border-left: 3px double var(--lp-red); }
.e-no { padding-inline: 0; text-align: center; font-size: 0.95rem; color: var(--lp-ink-2); }
.e-name { font-family: var(--f-display); font-weight: 400; font-size: 1.5rem; line-height: var(--line); letter-spacing: 0.005em; }
.e-see {
  display: block;
  width: fit-content;
  line-height: var(--line);
  font-family: var(--f-mono);
  font-size: var(--t-xxs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lp-ink-3);
  text-decoration: none;
}
.e-see:hover { color: var(--lp-ink); text-decoration: underline; }
.e-see .arr { display: inline-block; transition: transform 0.2s var(--ease); }
.e-see:hover .arr { transform: translateX(3px); }
.e-debit p, .e-credit p { font-size: 1rem; line-height: var(--line); text-wrap: pretty; }
.e-debit p { color: var(--lp-ink); }
.e-credit p { color: var(--lp-ink-2); }
.e-lab {
  position: absolute;
  width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
/* the stamp is lifted out of the flow and the cell kept to whole lines, so a two-line stamp cannot throw off the ruling */
.e-bal { position: relative; min-height: calc(var(--line) * 3); }
.stamp {
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  top: 4px;
  display: block;
  width: fit-content;
  max-width: calc(100% - 1.8rem);
  padding: 5px 8px 4px;
  border: 2px solid currentColor;
  border-radius: 3px;
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transform: rotate(-3deg);
  transform-origin: left center;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -5 0 0 0 3.9'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -5 0 0 0 3.9'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.entry:nth-child(even) .stamp { transform: rotate(2deg); }
.stamp--blue { color: var(--ink-blue); }
.stamp--violet { color: var(--ink-violet); }
.stamp--amber { color: var(--ink-amber); }
.stamp--red { color: var(--ink-red); }
.folio-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 0.9rem;
  border-top: 3px double var(--lp-ink);
  font-style: italic;
  color: var(--lp-ink-2);
}
.folio-foot p { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; justify-content: flex-end; }
.folio-foot .folio-k { display: inline; }

@media (max-width: 60rem) {
  .folio-cols { display: none; }
  .folio-head { grid-template-columns: minmax(0, 1fr) auto; }
  .folio-title { grid-column: 1 / -1; grid-row: 1; text-align: left; }
  .folio-key { text-align: left; }
  .entries { margin-top: 1.5rem; box-shadow: inset 0 1px 0 var(--lp-ink); }
  .entry { grid-template-columns: 2.25rem minmax(0, 1fr); }
  .entry > * { padding-bottom: 0; }
  .e-no { grid-row: 1 / span 4; padding-top: var(--line); }
  .entry > * + * { border-left: 3px double var(--lp-red); }
  .e-item { padding-top: var(--line) !important; }
  .e-lab {
    position: static;
    width: auto; height: auto; overflow: visible; clip: auto;
    display: block;
    font-family: var(--f-mono);
    font-size: var(--t-xxs);
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    line-height: var(--line);
    color: var(--lp-ink-3);
  }
  .e-debit { padding-top: 0; }
  .e-bal { min-height: calc(var(--line) * 3); }
  .stamp { top: calc(var(--line) + 4px); }
}

/* ---------- errata: a slip tipped in after the folio ---------- */
.errata { background: #08161d; padding-block: clamp(4rem, 8vw, 7rem) clamp(5rem, 10vw, 9rem); }
.errata-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 3rem clamp(3rem, 7vw, 7rem);
  align-items: start;
}
.errata-words { position: sticky; top: calc(var(--head) + 3rem); }
.errata-k { color: var(--signal); }
.errata-title { font-size: var(--t-xl); margin-top: 1rem; }
.errata-lede { margin-top: 1.6rem; color: var(--mist); max-width: 28rem; }
.slip {
  position: relative;
  max-width: 38rem;
  background: linear-gradient(180deg, #f4edd6, #ece2c4);
  color: #2b2418;
  padding: 2.4rem clamp(1.4rem, 3.5vw, 2.6rem) 2.2rem;
  transform: rotate(1deg);
  box-shadow: 0 30px 50px -30px rgba(0, 0, 0, 0.9), 0 2px 6px rgba(0, 0, 0, 0.35);
}
.slip::before {
  /* the strip of paste along the edge where it was tipped in */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 12px;
  background: linear-gradient(180deg, rgba(122, 96, 48, 0.28), rgba(122, 96, 48, 0.06));
}
.slip-head { text-align: center; font-family: var(--f-display); font-weight: 400; font-size: 2rem; letter-spacing: 0.3em; text-transform: uppercase; padding-left: 0.3em; line-height: 1; }
.slip-sub { text-align: center; font-style: italic; font-size: var(--t-s); color: #5b4c34; margin-top: 0.5rem; }
.slip-list { margin-top: 1.6rem; border-top: 1px solid rgba(43, 36, 24, 0.5); }
.slip-list li { padding-block: 1.2rem; border-bottom: 1px solid rgba(43, 36, 24, 0.2); }
.slip-where { font-family: var(--f-mono); font-size: var(--t-xxs); font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: #6a3a1c; }
.slip-fix { margin-top: 0.4rem; font-size: 1.12rem; line-height: 1.4; }
.slip-fix i { color: #6a5a40; padding-inline: 0.1em; }
.slip-fix .arr { font-size: 0.85em; }
.slip-why { margin-top: 0.5rem; font-size: 0.9375rem; line-height: 1.55; color: #4a3f2c; }
@media (max-width: 52rem) {
  .errata-grid { grid-template-columns: minmax(0, 1fr); }
  .errata-words { position: static; }
  .slip { transform: none; }
}
