/* ---------- 5. Character sheet on the table, resume underneath, resume request form ---------- */
/* Printed labels in Atkinson, hand-filled values in Kalam (ballpoint blue). */
.table-front {
  display: flex; justify-content: center;
  padding: 84px 3% 40px;
  --ballpoint: #24407a;
}
@media (max-width: 520px) { .table-front { padding: 76px 0 28px; } }

.sheet-wrap { container: sheet / inline-size; position: relative; width: min(980px, 100%); }

/* The stack: the top page, plus the edges of the pages still under it */
.sheet-stack { position: relative; z-index: 1; transform: rotate(-0.6deg); }
.sheet-stack::before, .sheet-stack::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: #f1efe7; box-shadow: inset 0 0 0 1px #ddd8ca, 6px 8px 0 rgba(60, 40, 20, 0.16);
}
.sheet-stack::before { transform: translate(7px, 7px) rotate(0.9deg); }
.sheet-stack::after { transform: translate(13px, 13px) rotate(1.6deg); }
.sheet-stack[data-under="1"]::after, .sheet-stack[data-under="0"]::after { display: none; }
.sheet-stack[data-under="0"]::before { display: none; }

.sheet {
  position: relative;
  padding: 22px 26px 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px #e4dfd1, 9px 11px 0 rgba(60, 40, 20, 0.24);
}
@container sheet (max-width: 700px) { .sheet { padding: 18px 14px 14px; } }

.sheet-title {
  margin: 0 0 4px;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-soft);
}
.page-title {
  margin: 0 0 12px; padding-bottom: 6px;
  border-bottom: 3px double var(--ink);
  font-size: 1.05rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
}
.page-title:focus { outline: none; }
.page-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.page-num { color: var(--red); }

.sheet-k {
  margin: 0;
  font-family: var(--f-slide); font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink);
}
.sheet-box { position: relative; padding: 16px 12px 10px; border: 1.5px solid #3b3f44; border-radius: 6px; }
.sheet-box > .sheet-k:first-child { position: absolute; top: -0.7em; left: 9px; padding: 0 5px; background: var(--paper); }
.sheet-aside { margin: 0 0 12px; font-size: 0.78rem; color: var(--ink-soft); }
.hand { margin: 0; font-family: var(--f-hand); font-size: 1rem; line-height: 1.35; color: var(--ballpoint); }
.hand + .hand { margin-top: 6px; }

/* Header: big name box on the left, the rest in a grid of lines */
.sheet-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px 18px; align-items: end; margin-bottom: 14px; }
@container sheet (max-width: 700px) { .sheet-top { grid-template-columns: minmax(0, 1fr); } }
.sheet-name { padding: 8px 12px 6px; border: 1.5px solid #3b3f44; border-radius: 6px 22px 6px 6px; }
.sheet-name .sheet-fields { display: block; }
.sheet-name dd { font-size: 1.55rem; }
.sheet-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 14px; margin: 0; }
.sheet-fields.stacked { grid-template-columns: minmax(0, 1fr); }
@container sheet (max-width: 700px) { .sheet-head-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sf { display: flex; flex-direction: column-reverse; min-width: 0; }
.sf dt { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.sf dd {
  margin: 0; padding: 0 2px;
  border-bottom: 1px solid #8d9095;
  font-family: var(--f-hand); font-size: 1.08rem; line-height: 1.4; color: var(--ballpoint);
  overflow-wrap: anywhere;
}
.sf dd small { font-size: 0.8em; }

/* Three columns, like the printed sheet. One column on phones. */
.sheet-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.sheet-cols.cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@container sheet (max-width: 760px) { .sheet-cols, .sheet-cols.cols-2 { grid-template-columns: minmax(0, 1fr); } }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Column 1: ability scores down the left, saves and skills beside them */
.c1-split { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr); gap: 12px; align-items: start; }
.c1-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stats { list-style: none; margin: 0; padding: 8px 6px; display: flex; flex-direction: column; gap: 10px; background: #e9e6dc; border-radius: 6px; }
@container sheet (max-width: 420px) {
  .c1-split { grid-template-columns: minmax(0, 1fr); }
  .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stat {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 5px 3px 0;
  border: 1.5px solid #3b3f44; border-radius: 8px 8px 16px 16px; background: var(--paper);
  text-align: center;
}
.stat-name { font-size: 0.56rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.15; min-height: 2.3em; display: flex; align-items: center; }
.stat-val { font-family: var(--f-hand); font-weight: 700; font-size: 1.7rem; line-height: 1.1; color: var(--ballpoint); }
.stat-mod {
  min-width: 2.6em; margin-bottom: -0.7em; padding: 0 5px;
  border: 1.5px solid #3b3f44; border-radius: 999px; background: var(--paper);
  font-family: var(--f-hand); font-size: 0.9rem; line-height: 1.3; color: var(--ballpoint);
}
.stat:has(.stat-note) { padding-bottom: 0; }
.stat-note { position: absolute; right: -0.4em; top: -0.9em; padding: 0 3px; background: var(--paper); font-family: var(--f-hand); font-size: 0.78rem; line-height: 1.2; color: var(--red); transform: rotate(6deg); }
.stat.is-over .stat-val { position: relative; color: var(--red); }
.stat.is-over .stat-val::after { /* circled in red pen */
  content: ""; position: absolute; left: 50%; top: 50%; width: 1.9em; height: 1.25em;
  transform: translate(-50%, -50%) rotate(-6deg);
  border: 2px solid var(--red); border-radius: 50%;
  pointer-events: none;
}
.stats li:last-child { margin-bottom: 8px; }

.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 6px 6px 5px; border: 1.5px solid #3b3f44; border-radius: 6px; text-align: center;
}
.tile-v { font-family: var(--f-hand); font-weight: 700; font-size: 1.45rem; line-height: 1.15; color: var(--ballpoint); overflow-wrap: anywhere; }
.tile-note { font-family: var(--f-hand); font-size: 0.85rem; line-height: 1.2; color: var(--ballpoint); }
.tile-k { margin-top: 2px; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.2; }
.tile-wide { flex-direction: row-reverse; justify-content: flex-end; gap: 10px; padding: 4px 10px; text-align: left; }
.tile-wide .tile-v { min-width: 2.2em; font-size: 1.2rem; text-align: center; border-right: 1.5px solid #3b3f44; padding-right: 8px; }
.tile-wide .tile-note { order: -1; }
.tile-wide .tile-k { margin: 0; flex: 1; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-column: 1 / -1; }
@container sheet (max-width: 560px) { .tiles-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile-shield { border-radius: 6px 6px 40% 40% / 6px 6px 18% 18%; min-height: 5.6rem; }
.hp { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.hp .tile:first-child { grid-column: 1 / -1; flex-direction: row-reverse; justify-content: space-between; gap: 8px; }
.hp .tile:first-child .tile-k { margin: 0; }
.tile-hp { min-height: 4.4rem; }

/* Saves and skills: a filled dot means proficient */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.checks li { display: flex; align-items: baseline; gap: 6px; font-size: 0.82rem; line-height: 1.3; }
.dot { flex: none; width: 0.62em; height: 0.62em; border-radius: 50%; background: var(--ballpoint); box-shadow: 0 0 0 1.5px var(--ink); transform: translateY(0.05em); }
.check-v { flex: none; min-width: 1.8em; font-family: var(--f-hand); color: var(--ballpoint); border-bottom: 1px solid #8d9095; text-align: center; }
.check-name { min-width: 0; overflow-wrap: anywhere; }

.attacks { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.attacks th { font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; text-align: left; padding: 0 4px 3px; }
.attacks td { padding: 3px 4px; border-bottom: 1px solid #b9bbbe; font-family: var(--f-hand); font-size: 0.95rem; line-height: 1.25; color: var(--ballpoint); vertical-align: top; }
.attacks td:nth-child(2) { white-space: nowrap; text-align: center; }

.coins { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px; margin: 0 0 8px; align-items: center; }
.coins dt { padding: 1px 6px; border: 1.5px solid #3b3f44; border-radius: 50%; font-size: 0.62rem; font-weight: 700; }
.coins dd { margin: 0; font-family: var(--f-hand); font-size: 1rem; color: var(--ballpoint); border-bottom: 1px solid #8d9095; }

.traits { display: flex; flex-direction: column; gap: 14px; padding: 12px 8px 8px; background: #e9e6dc; border-radius: 8px; }
.traits .sheet-box { background: var(--paper); }

.sheet-list { margin: 0; padding-left: 1.05rem; font-family: var(--f-hand); font-size: 1rem; line-height: 1.32; color: var(--ballpoint); }
.sheet-list li { margin: 3px 0; }

/* Page 3: spells */
.spells { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 18px 16px; }
.spell-note { margin: 0 0 6px; font-size: 0.74rem; color: var(--ink-soft); }
.spell-list { list-style: none; margin: 0; padding: 0; }
.spell-list li {
  display: flex; align-items: baseline; gap: 8px;
  padding: 2px 0; border-bottom: 1px solid #b9bbbe;
  font-family: var(--f-hand); font-size: 1.02rem; color: var(--ballpoint);
}
.spell-list li::before { content: ""; flex: none; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--ballpoint); box-shadow: 0 0 0 1.5px var(--ink); }

/* Back and Next */
.page-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 16px 0 0; padding-top: 12px; border-top: 1.5px solid #3b3f44;
}
.page-count { margin: 0; font-family: var(--f-device); font-size: 0.8rem; color: var(--ink-soft); white-space: nowrap; }
.page-btn {
  min-height: 44px; padding: 0 14px;
  border: 2px solid var(--ink); background: #fff; color: var(--ink);
  font-weight: 700; box-shadow: 3px 4px 0 var(--ink);
}
.page-btn:hover:not(:disabled) { background: #fff6e6; }
.page-btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 2px 0 var(--ink); }
.page-btn:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
.page-btn-next { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 3px 4px 0 var(--ink); }
.page-btn-next:hover:not(:disabled) { background: #26475a; }
@container sheet (max-width: 420px) { .page-btn { padding: 0 10px; font-size: 0.9rem; } .page-count { font-size: 0.72rem; } }
.sheet-page:not([hidden]) { animation: page-in 0.22s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Portrait = doodle pad ---------- */
.pad {
  position: relative;
  width: 100%; max-width: 16.5rem; margin: 0 auto;
  border: 1.5px solid #3b3f44;
  background: #fbfaf4;
}
.pad-canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 400 / 480;
  touch-action: none; cursor: crosshair;
}
.pad-prompt {
  position: absolute; inset: 0; margin: 0;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  font-family: var(--f-hand); font-size: 1.25rem; line-height: 1.3; text-align: center; color: #9a9b98;
  pointer-events: none;
}
.pad.has-ink .pad-prompt { visibility: hidden; }

.pad-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 10px 0 0; }
.pad-pens { display: flex; gap: 2px; margin-right: 4px; }
.pad-pen {
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent;
  display: grid; place-items: center;
}
.pad-pen::before { content: ""; width: 20px; height: 20px; border-radius: 50%; background: var(--pen); box-shadow: 0 0 0 2px var(--paper); }
.pad-pen[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--ink); }
.pad-tool, .pad-send {
  min-height: 40px; padding: 0 12px;
  border: 2px solid var(--ink); background: #fff; color: var(--ink);
  font-weight: 700; font-size: 0.9rem;
}
.pad-tool:hover:not(:disabled), .pad-send:hover:not(:disabled) { background: #fff6e6; }
.pad-tool:disabled, .pad-send:disabled { opacity: 0.45; cursor: default; }
.pad-sign-label { display: block; margin: 12px 0 2px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.pad-sign {
  width: 100%; min-height: 40px; padding: 4px 6px;
  border: 0; border-bottom: 1.5px solid #3b3f44; background: transparent;
  font-family: var(--f-hand); font-size: 1.1rem; color: var(--ballpoint);
}
.pad-send {
  display: block; width: 100%; margin: 12px 0 0; min-height: 44px;
  background: var(--accent); border-color: var(--accent); color: #fff; font-size: 1rem;
}
.pad-send:hover:not(:disabled) { background: #26475a; }
.pad-note { margin: 8px 0 0; font-size: 0.78rem; color: var(--ink-soft); text-align: center; }

.ts-slot:not(:empty) { margin: 10px 0 0; }
.form-status { min-height: 0; margin: 8px 0 0; font-size: 0.9rem; font-weight: 700; overflow-wrap: anywhere; }
.form-status:empty { display: none; }
.form-status.is-ok { color: var(--go); }
.form-status.is-error { color: var(--red); }

/* ---------- The resume, peeking out from under the sheet ---------- */
.resume-peek {
  position: absolute; z-index: 0; top: -66px; right: 7%;
  width: min(17rem, 64%); height: 150px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0;
  padding: 10px 16px 0;
  border: 0; background: #fff; color: var(--ink); text-align: left;
  transform: rotate(3.5deg); transform-origin: 0 100%;
  box-shadow: inset 0 0 0 1px #e1ddd2, 5px 6px 0 rgba(60, 40, 20, 0.18);
  transition: transform 0.18s ease;
}
.resume-peek:hover, .resume-peek:focus-visible { transform: translateY(-10px) rotate(3.5deg); }
.resume-peek:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.peek-title { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; }
.peek-line { font-family: var(--f-hand); font-size: 1.12rem; line-height: 1.3; color: var(--red); }
.peek-rules {
  align-self: stretch; height: 40px; margin-top: 6px;
  background: repeating-linear-gradient(180deg, #d6d3ca 0 2px, transparent 2px 9px);
}
@container sheet (max-width: 420px) {
  .resume-peek { top: -74px; right: 3%; width: 84%; }
  .peek-line { font-size: 1.05rem; }
}

.contact-resume { text-align: left; align-items: flex-start; font: inherit; color: inherit; }

/* ---------- Resume request form (native <dialog>) ---------- */
html.has-modal { overflow: hidden; }
.request {
  width: min(30rem, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  margin: auto; padding: 0; border: 0;
  background: var(--paper); color: var(--ink);
  box-shadow: 9px 11px 0 rgba(0, 0, 0, 0.3);
  overflow: auto; overscroll-behavior: contain;
}
.request::backdrop { background: rgba(38, 33, 24, 0.72); }
.request-form { position: relative; display: flex; flex-direction: column; padding: 30px 24px 22px; }
.request-clip {
  position: absolute; top: 0; left: 50%; width: 76px; height: 14px; margin-left: -38px;
  background: #3a3b3d; border-radius: 0 0 4px 4px;
}
.request-title { margin: 0; font-size: 1.45rem; line-height: 1.15; }
.request-intro { margin: 6px 0 8px; color: var(--ink-soft); }
.request-label { margin: 12px 0 3px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.request-input {
  min-height: 44px; padding: 6px 10px;
  border: 2px solid var(--ink); border-radius: 0; background: #fff; color: var(--ink);
  font: inherit; font-size: 1rem;
}
.request-input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.request-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
.request-btn {
  min-height: 44px; padding: 0 16px;
  border: 2px solid var(--ink); background: #fff; color: var(--ink);
  font-weight: 700;
}
.request-btn:hover:not(:disabled) { background: #fff6e6; }
.request-send { background: var(--accent); border-color: var(--accent); color: #fff; }
.request-send:hover:not(:disabled) { background: #26475a; }
.request-send:disabled { opacity: 0.6; cursor: default; }

/* Phones: skills in two columns so page 1 stays shorter; Back and Next stay on one line */
@container sheet (max-width: 760px) { .sb-skills .checks { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; } }
.page-btn { white-space: nowrap; }
@container sheet (max-width: 420px) { .page-btn { min-height: 44px; padding: 0 9px; font-size: 0.85rem; } .page-nav { gap: 6px; } }
.tiles-4 .tile-shield { min-height: 4.4rem; }
