/* ==========================================================================
   Character Sheet Page (csp-*)
   US Letter-proportioned preview inside site nav.
   Route: /characters/:id/sheet
   ========================================================================== */

.csp-wrapper {
  padding: 1rem;
}

.csp-page {
  width: 100%;
  max-width: 760px;
  aspect-ratio: 8.5 / 11;
  background: #fff;
  color: #111;
  margin: 0 auto;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  font-size: clamp(8px, 1.15vw, 11px);
  border: 1px solid #aaa;
  overflow: hidden;
}

/* ==========================================================================
   Section proportions (17 / 30 / 38 / 15)
   ========================================================================== */

.csp-s1 { flex: 17; display: flex; border-bottom: 1px solid #999; }
.csp-s2 { flex: 30; display: flex; border-bottom: 1px solid #999; }
.csp-s3 { flex: 38; display: flex; flex-direction: column; border-bottom: 1px solid #999; }
.csp-s4 { flex: 15; display: flex; }

/* ==========================================================================
   Section 1 — Identity
   ========================================================================== */

.csp-s1-left {
  width: 63%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #999;
}

.csp-s1-name {
  flex: 62;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.4em 0.6em;
  border-bottom: 1px solid #ccc;
}

.csp-s1-background {
  flex: 38;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.3em 0.6em;
}

.csp-s1-right {
  width: 37%;
  display: flex;
  flex-direction: column;
}

.csp-s1-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.25em 0.5em;
  border-bottom: 1px solid #ccc;
}

.csp-s1-detail:last-child {
  border-bottom: none;
}

.csp-field-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72em;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.csp-field-value {
  font-family: 'Fraunces', serif;
  font-size: 1.05em;
  font-weight: 600;
  color: #111;
  margin-top: 0.1em;
}

/* ==========================================================================
   Section 2 — Portrait + Stats
   ========================================================================== */

.csp-s2-portrait {
  width: 60%;
  border-right: 1px solid #999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8e8e8;
  overflow: hidden;
}

.csp-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.csp-portrait-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #999;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}

.csp-s2-stats {
  width: 40%;
  display: flex;
  flex-direction: column;
  padding: 0.4em 0.5em;
  gap: 0.25em;
}

.csp-stat-header {
  display: flex;
  align-items: center;
  padding: 0 0.3em 0.2em;
  border-bottom: 1px solid #ccc;
  margin-bottom: 0.1em;
}

.csp-stat-header-label { flex: 1; }

.csp-stat-header-max,
.csp-stat-header-cur {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72em;
  color: #666;
  text-transform: uppercase;
  width: 2.5em;
  text-align: center;
}

/* Chamfered stat box — 6px cuts */
.csp-maus-stat {
  display: flex;
  align-items: center;
  padding: 0.18em 0.3em;
  clip-path: polygon(
    6px 0%, calc(100% - 6px) 0%, 100% 6px,
    100% calc(100% - 6px), calc(100% - 6px) 100%,
    6px 100%, 0% calc(100% - 6px), 0% 6px
  );
  background: #e6e6e6;
}

.csp-maus-stat-label {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75em;
  font-weight: 500;
  text-transform: uppercase;
  color: #333;
}

.csp-maus-stat-nums {
  display: flex;
  gap: 0.3em;
}

.csp-maus-stat-max,
.csp-maus-stat-cur {
  font-family: 'Fraunces', serif;
  font-size: 1em;
  font-weight: 700;
  width: 2.2em;
  text-align: center;
  color: #111;
}

.csp-maus-pips-row {
  display: flex;
  align-items: center;
  margin-top: auto;
  padding-top: 0.3em;
  border-top: 1px solid #ccc;
}

.csp-pips-label {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72em;
  color: #666;
  text-transform: uppercase;
}

.csp-pips-val {
  font-family: 'Fraunces', serif;
  font-size: 0.95em;
  font-weight: 600;
  color: #111;
}

/* ==========================================================================
   Section 3 — Inventory
   ========================================================================== */

.csp-inv-head {
  flex: 12;
  display: flex;
  align-items: center;
  padding: 0.3em 0.6em;
  border-bottom: 1px solid #bbb;
  background: #f0f0f0;
}

.csp-inv-title {
  font-family: 'Fasthand', cursive;
  font-size: 1.4em;
  color: #222;
}

.csp-inv-body {
  flex: 73;
  display: flex;
  border-bottom: 1px solid #bbb;
}

.csp-inv-row-labels {
  width: 18%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #bbb;
}

.csp-inv-paw-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72em;
  color: #555;
  text-transform: uppercase;
  writing-mode: horizontal-tb;
  padding: 0.3em 0.2em;
  border-bottom: 1px solid #ccc;
}

.csp-inv-paw-label:last-child { border-bottom: none; }

.csp-inv-grid {
  width: 60%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0.35em;
  padding: 0.35em;
  border-right: 1px solid #bbb;
}

/* Chamfered inventory slot — 12px cuts */
.csp-maus-slot {
  position: relative;
  background: #d0d0d0;
  clip-path: polygon(
    12px 0%, calc(100% - 12px) 0%, 100% 12px,
    100% calc(100% - 12px), calc(100% - 12px) 100%,
    12px 100%, 0% calc(100% - 12px), 0% 12px
  );
  overflow: hidden;
}

.csp-maus-slot-num {
  position: absolute;
  top: 0.2em;
  left: 0.35em;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68em;
  color: #888;
  z-index: 3;
}

.csp-maus-item-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

.csp-maus-item-img.csp-img-gone {
  display: none;
}

.csp-maus-item-name {
  position: absolute;
  bottom: 0.2em;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.72em;
  z-index: 1;
  padding: 0.15em 0.2em;
  background: rgba(255, 255, 255, 0.85);
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csp-inv-banked {
  width: 22%;
  display: flex;
  flex-direction: column;
  padding: 0.4em 0.4em;
}

.csp-banked-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 0.3em;
  display: block;
}

.csp-banked-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow: hidden;
}

.csp-banked-item {
  font-size: 0.78em;
  color: #333;
  padding: 0.1em 0;
  border-bottom: 1px solid #ddd;
}

.csp-banked-empty {
  font-size: 0.8em;
  color: #999;
}

.csp-inv-legend {
  flex: 15;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0.25em 0.5em;
  background: #f5f5f5;
}

.csp-legend-item {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65em;
  color: #555;
}

/* ==========================================================================
   Section 4 — Footer (level / grit / brand)
   ========================================================================== */

.csp-s4 {
  display: flex;
  align-items: stretch;
  padding: 0.4em 0.6em;
  gap: 0.6em;
}

.csp-s4-level,
.csp-s4-grit {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
}

/* Chamfered footer box — 8px cuts */
.csp-chamfer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.3em 0.8em;
  clip-path: polygon(
    8px 0%, calc(100% - 8px) 0%, 100% 8px,
    100% calc(100% - 8px), calc(100% - 8px) 100%,
    8px 100%, 0% calc(100% - 8px), 0% 8px
  );
  background: #e6e6e6;
  min-width: 3.5em;
}

.csp-s4-big-val {
  font-family: 'Fraunces', serif;
  font-size: 1.6em;
  font-weight: 700;
  color: #111;
  line-height: 1;
}

.csp-s4-box-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65em;
  text-transform: uppercase;
  color: #666;
}

.csp-xp-line,
.csp-grit-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68em;
  color: #555;
  text-align: center;
}

.csp-s4-conditions {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3em;
  padding: 0 0.4em;
}

.csp-conditions-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65em;
  text-transform: uppercase;
  color: #666;
  width: 100%;
}

.csp-condition-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7em;
  background: #d0d0d0;
  color: #333;
  padding: 0.1em 0.4em;
  border-radius: 2px;
  clip-path: polygon(
    4px 0%, calc(100% - 4px) 0%, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 0% calc(100% - 4px), 0% 4px
  );
}

.csp-s4-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.3em;
}

.csp-brand-text {
  font-family: 'Fasthand', cursive;
  font-size: 1.2em;
  color: #888;
}

.csp-print-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68em;
  color: #888;
  text-decoration: none;
}

.csp-print-link:hover {
  color: #444;
  text-decoration: underline;
}

/* ==========================================================================
   Unsupported message
   ========================================================================== */

.csp-unsupported {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary, #b0b0b0);
}

.csp-unsupported p {
  margin-bottom: 1rem;
}

/* ==========================================================================
   Sheet2 — Mausritter PNG overlay (csp2-*)
   All data fields are absolutely positioned over the character-sheet.png.
   Pixel reference: 521 × 748 PNG (aspect-ratio preserved in container).
   ========================================================================== */

.csp2-wrapper {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- Print action bar (above the sheet, hidden when printing) ---- */
.csp2-print-bar {
  width: 100%;
  max-width: 760px;
  display: flex;
  justify-content: flex-end;
  padding: 0.3rem 0;
  margin-bottom: 0.25rem;
}

/* ---- Admin editor bar (above the sheet) ---- */
.csp2-editor-bar {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.5rem;
  background: var(--bg-secondary, #0a0a0a);
  border: 1px solid var(--border-primary, #2a2a2a);
  border-radius: 4px;
  flex-wrap: wrap;
}

.csp2-editor-coords {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary, #b0b0b0);
  padding: 0.2rem 0.5rem;
  background: var(--bg-hover, #242424);
  border-radius: 3px;
}

.csp2-css-output {
  width: 100%;
  max-width: 760px;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.csp2-css-output textarea {
  width: 100%;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  background: var(--bg-secondary, #0a0a0a);
  color: var(--text-primary, #e8e8e8);
  border: 1px solid var(--border-primary, #2a2a2a);
  border-radius: 4px;
  padding: 0.5rem;
  resize: vertical;
}

.csp2-page {
  position: relative;
  width: 100%;
  max-width: 760px;
  aspect-ratio: 521 / 748;
  background-image: url('/images/mausritter/character-sheet.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  margin: 0 auto;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.45);
  font-size: clamp(7px, 1.45vw, 13px);
  overflow: hidden;
}

/* ---- Identity ---- */
.csp2-name {
  position: absolute;
  top: 5.6%;
  left: 16.5%;
  width: 40.2%;
  font-family: 'Fraunces', serif;
  font-size: 1.2em;
  font-weight: 700;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
}

.csp2-background {
  position: absolute;
  top: 10.3%;
  left: 17.3%;
  width: 38.8%;
  font-family: 'Fraunces', serif;
  font-size: 1.0em;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
}

.csp2-birthsign {
  position: absolute;
  top: 4.3%;
  left: 69.1%;
  width: 26.3%;
  font-family: 'Fraunces', serif;
  font-size: 0.85em;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
}

.csp2-coat {
  position: absolute;
  top: 7.7%;
  left: 69.1%;
  width: 24.4%;
  font-family: 'Fraunces', serif;
  font-size: 0.85em;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
}

.csp2-look {
  position: absolute;
  top: 10.7%;
  left: 69.4%;
  width: 24.1%;
  font-family: 'Fraunces', serif;
  font-size: 0.85em;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
}

/* ---- Portrait ---- */
.csp2-portrait {
  position: absolute;
  top: 14.5%;
  left: 3.0%;
  width: 52.0%;
  height: 36.5%;
  object-fit: cover;
}

/* ---- Stats — right column ---- */
.csp2-stat-val {
  position: absolute;
  font-family: 'Fraunces', serif;
  font-size: 1.35em;
  font-weight: 700;
  color: #111;
  text-align: center;
  width: 9%;
  line-height: 1;
}

/* left values are left-edge coordinates (no translateX transform) */
.csp2-str-max { top: 25.4%; left: 72.8%; }
.csp2-str-cur { top: 25.5%; left: 84.5%; }
.csp2-dex-max { top: 30.9%; left: 72.7%; }
.csp2-dex-cur { top: 31.0%; left: 84.8%; }
.csp2-wil-max { top: 36.3%; left: 72.7%; }
.csp2-wil-cur { top: 36.3%; left: 84.7%; }
.csp2-hp-max { top: 43.7%; left: 72.8%; }
.csp2-hp-cur { top: 43.7%; left: 84.8%; }

/* ---- Pips ---- */
.csp2-pips {
  position: absolute;
  top: 52.2%;
  left: 85.3%;
  font-family: 'Fraunces', serif;
  font-size: 1.05em;
  font-weight: 600;
  color: #111;
}

/* ---- Inventory slots — overlaid on the PNG's chamfered boxes ---- */
/* Slot grid: 3 cols × 2 rows; left edge ~22%, each slot ~19% wide.  */
/* Row 1 top ~70.5%, row 2 top ~82.5%; each row ~12% tall.           */
.csp2-slot {
  position: absolute;
  overflow: hidden;
}

.csp2-slot-1 { top: 56.0%; left: 41.9%; width: 18.5%; height: 12.0%; }
.csp2-slot-2 { top: 56.0%; left: 59.1%; width: 18.5%; height: 12.0%; }
.csp2-slot-3 { top: 56.1%; left: 76.4%; width: 18.5%; height: 12.0%; }
.csp2-slot-4 { top: 68.4%; left: 41.9%; width: 18.5%; height: 11.5%; }
.csp2-slot-5 { top: 68.4%; left: 59.3%; width: 18.5%; height: 11.5%; }
.csp2-slot-6 { top: 68.3%; left: 76.6%; width: 18.5%; height: 11.5%; }

.csp2-paw-1  { top: 56.0%; left:  3.0%; width: 18.5%; height: 12.0%; }
.csp2-body-1 { top: 56.0%; left: 22.0%; width: 18.5%; height: 12.0%; }
.csp2-paw-2  { top: 68.4%; left:  3.0%; width: 18.5%; height: 11.5%; }
.csp2-body-2 { top: 68.4%; left: 22.0%; width: 18.5%; height: 11.5%; }

.csp2-slot-img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 2;
}

.csp2-slot-img.csp-img-gone {
  display: none;
}

.csp2-slot-name {
  position: absolute;
  bottom: 3%;
  left: 0; right: 0;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68em;
  color: #111;
  background: rgba(215, 205, 185, 0.9);
  padding: 0.1em 0.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 3;
}

/* ---- Banked items ---- */
.csp2-banked {
  position: absolute;
  top: 87.1%;
  left: 61.6%;
  width: 30.5%;
  height: 6.7%;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7em;
  color: #333;
  overflow: hidden;
  padding: 0.3em 0.2em;
}

.csp2-banked-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.csp2-banked-list li {
  padding: 0.12em 0;
  border-bottom: 1px dotted #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Footer ---- */
.csp2-level {
  position: absolute;
  top: 84.1%;
  left: 14.8%;
  font-family: 'Fraunces', serif;
  font-size: 1.5em;
  font-weight: 700;
  color: #111;
  line-height: 1;
}

.csp2-xp {
  position: absolute;
  top: 93.8%;
  left: 8.3%;
  width: 9.3%;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68em;
  color: #444;
}

.csp2-grit {
  position: absolute;
  top: 84.1%;
  left: 31.0%;
  font-family: 'Fraunces', serif;
  font-size: 1.5em;
  font-weight: 700;
  color: #111;
  line-height: 1;
}

.csp2-conditions {
  position: absolute;
  top: 93.5%;
  left: 28%;
  width: 38%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em;
  align-items: flex-start;
}

.csp2-condition {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68em;
  color: #333;
  background: rgba(180, 170, 150, 0.55);
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

/* ---- Print: isolate just the sheet, fill the full page ---- */
@media print {
  @page { margin: 0; }
  /* Clamp to one page — prevents invisible content from generating page 2 */
  html, body { height: 100vh; overflow: hidden; }
  body * { visibility: hidden; }
  .csp2-page,
  .csp2-page * { visibility: visible; }
  .csp2-page {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    box-shadow: none;
    margin: 0;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
