/* District character sheet additions.
   Screen view keeps the existing District/P.I.N. interface.
   The clean paper sheet is used only when printing. */

.character-wrap{ max-width:1100px; }
.sheet-top{ flex-wrap:wrap; }

.pin-panel{
  display:grid;
  grid-template-columns:auto 1fr;
  align-items:stretch;
  padding:0;
  margin-bottom:18px;
}

.pin-brand{
  display:flex;
  align-items:center;
  gap:14px;
  padding:12px 18px;
  border-right:1px solid rgba(14,42,28,.9);
}

.pin-mark{
  font-weight:900;
  font-size:34px;
  letter-spacing:-.08em;
}

.pin-name{
  font-size:9px;
  line-height:1.2;
  letter-spacing:.08em;
}

.character-nav{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(105px,1fr));
}

.character-button{
  min-width:0;
  border:0;
  border-right:1px solid rgba(14,42,28,.65);
  border-bottom:1px solid rgba(14,42,28,.35);
  background:transparent;
  color:var(--dim);
  padding:14px 8px;
  cursor:pointer;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font:inherit;
}

.character-button:hover{ background:rgba(140,255,205,.04); }
.character-button.active{
  color:var(--txt);
  background:rgba(140,255,205,.10);
  box-shadow:inset 0 -2px 0 var(--txt);
}
.character-button .nav-state{
  opacity:.65;
  margin-left:5px;
  font-size:.8em;
}

#editor{ display:block; }
.sheet-editor-wrap{ width:100%; }

.sheet-editor-tools{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
  gap:8px;
  margin:0 0 8px;
}

.sheet-editor-tools .record-status{
  margin-right:auto;
  font-size:10px;
  color:var(--dim);
}

.sheet-tool-button{
  border:1px solid rgba(111,215,163,.35);
  background:rgba(0,0,0,.20);
  color:var(--txt);
  border-radius:5px;
  padding:8px 10px;
  cursor:pointer;
  font:inherit;
  font-size:10px;
}
.sheet-tool-button:hover{ background:rgba(140,255,205,.06); }
.sheet-tool-button.danger{ border-style:dashed; }

.record-sheet{
  width:100%;
  border:1px solid rgba(14,42,28,.9);
  background:linear-gradient(to bottom, rgba(10,25,16,.78), rgba(6,14,10,.7));
  color:var(--txt);
  box-shadow:0 18px 60px rgba(0,0,0,.48);
  border-radius:var(--radius);
  overflow:hidden;
}

.record-sheet *{ box-sizing:border-box; }

.record-sheet input,
.record-sheet textarea{
  width:100%;
  border:1px solid rgba(111,215,163,.25);
  background:rgba(0,0,0,.22);
  color:var(--txt);
  font:inherit;
  border-radius:5px;
  padding:8px 9px;
  outline:none;
}

.record-sheet textarea{ resize:vertical; }

.record-sheet input:focus,
.record-sheet textarea:focus{
  border-color:rgba(191,255,215,.65);
  box-shadow:0 0 0 2px rgba(140,255,205,.08);
}

.record-sheet input:disabled,
.record-sheet textarea:disabled,
.record-sheet button:disabled{
  opacity:.55;
  cursor:default;
}

.sheet-label,
.section-title{
  display:block;
  margin:0 0 6px;
  font-size:10px;
  color:var(--dim);
  letter-spacing:.06em;
  text-transform:uppercase;
}

.sheet-identity{
  display:grid;
  grid-template-columns:1fr auto;
  gap:18px;
  align-items:end;
  padding:18px;
  border-bottom:1px solid rgba(14,42,28,.9);
}

.identity-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.identity-grid.has-origin-hab .identity-origin-hab{ grid-column:1 / -1; }

/* HAB records */
.hab-sheet{ min-height:520px; }
.hab-record-heading{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:18px;
  border-bottom:1px solid rgba(14,42,28,.9);
}
.hab-record-number{
  font-size:22px;
  font-weight:800;
  letter-spacing:.08em;
}
.hab-sheet-main{
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:22px;
}
.hab-top-row{
  display:grid;
  grid-template-columns:55fr 15fr 15fr 15fr;
  gap:10px;
}
.hab-top-row input{ text-align:center; }
.hab-top-row label:first-child input{ text-align:left; }
.hab-blocks-section{ padding-top:4px; }
.hab-block-grid{
  display:grid;
  grid-template-columns:repeat(6,1fr);
  gap:10px;
}
.hab-block-slot{
  position:relative;
  min-height:92px;
  padding:12px;
  border:1px solid rgba(111,215,163,.25);
  border-radius:5px;
  background:rgba(0,0,0,.16);
  overflow:hidden;
}
.hab-block-slot input{ min-height:44px; }
.hab-block-slot.is-unavailable{
  opacity:.38;
  background:rgba(0,0,0,.34);
}
.hab-block-slot.is-unavailable::before,
.hab-block-slot.is-unavailable::after{
  content:"";
  position:absolute;
  left:-8%;
  top:50%;
  width:116%;
  height:1px;
  background:rgba(111,215,163,.55);
  pointer-events:none;
}
.hab-block-slot.is-unavailable::before{ transform:rotate(18deg); }
.hab-block-slot.is-unavailable::after{ transform:rotate(-18deg); }
.hab-sheet.is-lost{ opacity:.7; }

.level-display,
.gang-level-box{
  min-height:39px;
  border:1px solid rgba(111,215,163,.25);
  background:rgba(0,0,0,.22);
  color:var(--txt);
  border-radius:5px;
  padding:8px 9px;
  display:flex;
  align-items:center;
  font-weight:700;
}

.sheet-brand-row{
  text-align:right;
  min-width:125px;
}

.sheet-brand .pin-large{
  font-size:38px;
  font-weight:900;
  line-height:.9;
  letter-spacing:-.08em;
}

.sheet-brand .pin-small{
  margin-top:7px;
  font-size:8px;
  line-height:1.15;
  letter-spacing:.06em;
  font-weight:600;
}

.sheet-record-type{
  margin-top:9px;
  font-size:9px;
  color:var(--dim);
  letter-spacing:.08em;
}

.stat-bar{
  display:grid;
  grid-template-columns:repeat(8,1fr);
  border-bottom:1px solid rgba(14,42,28,.9);
}

.stat-cell{
  padding:10px;
  border-right:1px solid rgba(14,42,28,.65);
  text-align:center;
}
.stat-cell:last-child{ border-right:0; }
.stat-name{
  display:block;
  font-weight:800;
  margin-bottom:5px;
}
.stat-cell input{
  text-align:center;
  font-size:20px;
  padding:6px 2px;
}

.sheet-main{
  display:grid;
  grid-template-columns:minmax(0,1.65fr) minmax(250px,.7fr);
}

.sheet-left{
  border-right:1px solid rgba(14,42,28,.9);
  min-width:0;
  display:flex;
  flex-direction:column;
}

.sheet-right{
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:16px;
}

.weapon-block{
  padding:16px;
  border-bottom:1px solid rgba(14,42,28,.9);
}

.weapon-name-row{
  display:grid;
  grid-template-columns:4fr 1fr;
  gap:8px;
  margin-bottom:10px;
}

.weapon-profile{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:8px;
  margin-bottom:10px;
}

.weapon-name-row label,
.weapon-profile label,
.weapon-rules{
  min-width:0;
}

.weapon-name-row input,
.weapon-profile input{ text-align:center; }

.weapon-rules textarea{
  min-height:76px;
}

.skills-block{
  padding:16px;
  flex:1;
  display:flex;
  flex-direction:column;
}

.skills-block textarea{
  min-height:220px;
  flex:1;
}

.tracker-block{
  border-bottom:1px solid rgba(14,42,28,.65);
  padding-bottom:15px;
}

.tracker-title{
  font-size:11px;
  margin-bottom:8px;
}

.tracker-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:6px;
}

.track-box{
  aspect-ratio:1;
  border:1px solid rgba(111,215,163,.35);
  background:rgba(0,0,0,.20);
  cursor:pointer;
  position:relative;
  color:var(--txt);
  padding:0;
}
.track-box.marked::after{
  content:"×";
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  font-size:24px;
}

.downs-block{
  border-bottom:1px solid rgba(14,42,28,.65);
  padding-bottom:15px;
}

.counter-row{
  display:flex;
  align-items:center;
  gap:8px;
}

.counter-value{
  min-width:52px;
  text-align:center;
  font-size:20px;
  font-weight:700;
}

.counter-button{
  width:34px;
  height:34px;
  padding:0;
  border:1px solid rgba(111,215,163,.35);
  background:rgba(0,0,0,.20);
  color:var(--txt);
  border-radius:5px;
  cursor:pointer;
}

.xp-block{ margin-top:auto; }
.xp-block input{
  width:100%;
  font-size:26px;
  text-align:center;
}

/* Gang panel */
.gang-sheet .sheet-identity{ align-items:end; }
.gang-summary-row{
  display:grid;
  grid-template-columns:2fr 1fr;
  gap:12px;
}
.gang-standing{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.gang-standing-title{ display:block; }
.gang-standing-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}
.gang-standing-grid input{ text-align:center; }
.gang-level-box{ justify-content:center; }

.gang-sheet-main{
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:18px;
}

.gang-section{
  padding-bottom:18px;
  border-bottom:1px solid rgba(14,42,28,.65);
}

.resource-grid,
.hab-grid{
  display:grid;
  gap:10px;
}
.resource-grid{ grid-template-columns:repeat(5,1fr); }
.hab-grid{ grid-template-columns:repeat(4,1fr); }
.resource-grid input,
.hab-grid input{ text-align:center; }

.warehouse-head,
.warehouse-row{
  display:grid;
  grid-template-columns:1fr;
  gap:8px;
}

.warehouse-head{
  margin-bottom:6px;
  font-size:10px;
  color:var(--dim);
}
.warehouse-head span:nth-child(2){ text-align:center; }
.warehouse-list{ display:grid; gap:6px; }
.warehouse-row input:nth-child(2){ text-align:center; }

.gang-ended{
  min-height:420px;
  border:1px solid rgba(111,215,163,.35);
  background:linear-gradient(to bottom, rgba(10,25,16,.78), rgba(6,14,10,.7));
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:30px;
}
.gang-ended[hidden]{ display:none; }
.gang-ended-message{
  font-size:clamp(1.8rem,5vw,4rem);
  font-weight:900;
  letter-spacing:.08em;
}
.gang-ended-sub{
  margin-top:18px;
  font-size:clamp(.8rem,2vw,1.2rem);
  letter-spacing:.12em;
  color:var(--dim);
}

.sheet-actions{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:10px;
  margin-top:18px;
}
.import-label{ cursor:pointer; }
.import-label input{ display:none; }
.save-status{
  margin-left:auto;
  color:var(--dim);
  font-size:10px;
}

#printArea{ display:none; }

@media (max-width:760px){
  .pin-panel{ grid-template-columns:1fr; }
  .pin-brand{ border-right:0; border-bottom:1px solid rgba(14,42,28,.9); }
  .character-nav{ grid-template-columns:repeat(auto-fit,minmax(105px,1fr)); }
  .sheet-identity{ grid-template-columns:1fr; }
  .sheet-brand-row{ text-align:left; }
  .identity-grid{ grid-template-columns:1fr; }
  .stat-bar{ grid-template-columns:repeat(4,1fr); }
  .stat-cell:nth-child(4n){ border-right:0; }
  .stat-cell:nth-child(-n+4){ border-bottom:1px solid rgba(14,42,28,.65); }
  .sheet-main{ grid-template-columns:1fr; }
  .sheet-left{ border-right:0; border-bottom:1px solid rgba(14,42,28,.9); }
  .resource-grid,.hab-grid{ grid-template-columns:repeat(2,1fr); }
  .hab-top-row{ grid-template-columns:1fr 1fr; }
  .hab-top-row label:first-child{ grid-column:1 / -1; }
  .hab-block-grid{ grid-template-columns:1fr 1fr; }
  .save-status{ width:100%; margin-left:0; }
}

@page{ size:A4 landscape; margin:0; }

@media print{
  body{
    background:#fff !important;
    color:#000 !important;
    font-family:Arial,sans-serif;
  }

  .bg-noise,
  .sheet-top,
  .pin-panel,
  #editor,
  .sheet-actions,
  .gang-ended{
    display:none !important;
  }

  .character-wrap{
    max-width:none;
    width:auto;
    margin:0;
    padding:0;
  }

  #printArea{ display:block !important; }

  .print-page{
    width:297mm;
    height:210mm;
    display:grid;
    grid-template-columns:148.5mm 148.5mm;
    grid-template-rows:210mm;
    break-after:page;
    page-break-after:always;
    overflow:hidden;
  }
  .print-page:last-child{ break-after:auto; page-break-after:auto; }

  .print-slot{
    width:148.5mm;
    height:210mm;
    padding:5mm;
    color:#000;
    background:#fff;
    overflow:hidden;
  }
  .print-slot:first-child{ border-right:1px dashed #aaa; }

  .print-slot .record-sheet{
    width:100%;
    height:100%;
    border:1.5px solid #000;
    border-radius:0;
    background:#fff;
    color:#000;
    box-shadow:none;
    overflow:hidden;
    display:grid;
    grid-template-rows:auto auto 1fr;
    font-family:Arial,sans-serif;
  }

  .print-slot .record-sheet input,
  .print-slot .record-sheet textarea,
  .print-slot .level-display,
  .print-slot .gang-level-box{
    color:#000 !important;
    background:#fff !important;
    border:1px solid #000 !important;
    box-shadow:none !important;
    resize:none !important;
  }

  .print-slot .sheet-label,
  .print-slot .section-title,
  .print-slot .sheet-record-type,
  .print-slot .warehouse-head{
    color:#000 !important;
  }

  .print-slot .sheet-identity{
    grid-template-columns:1fr auto;
    padding:4mm;
    gap:3mm;
    border-color:#000;
  }
  .print-slot .identity-grid{ gap:2mm; }
  .print-slot .identity-grid input,.print-slot .level-display{ min-height:7.2mm; padding:1.2mm 1.5mm; font-size:9pt; }
  .print-slot .sheet-brand-row{ min-width:28mm; }
  .print-slot .sheet-brand .pin-large{ font-size:18pt; }
  .print-slot .sheet-brand .pin-small{ font-size:5pt; }
  .print-slot .sheet-record-type{ font-size:5pt; }

  .print-slot .stat-bar{ border-color:#000; }
  .print-slot .stat-cell{ padding:2mm 1mm; border-color:#000; }
  .print-slot .stat-cell input{ font-size:10pt; padding:1mm; }

  .print-slot .sheet-main{ grid-template-columns:minmax(0,1.65fr) minmax(34mm,.7fr); min-height:0; }
  .print-slot .sheet-left{ border-color:#000; min-height:0; }
  .print-slot .weapon-block{ padding:3mm; border-color:#000; }
  .print-slot .weapon-name-row{ gap:1.5mm; margin-bottom:2mm; }
  .print-slot .weapon-profile{ gap:1.5mm; margin-bottom:2mm; }
  .print-slot .weapon-name-row input,.print-slot .weapon-profile input{ padding:1mm; font-size:8pt; }
  .print-slot .weapon-rules textarea{ min-height:18mm; height:18mm; padding:1mm; }
  .print-slot .skills-block{ padding:3mm; min-height:0; }
  .print-slot .skills-block textarea{ min-height:43mm; height:43mm; padding:1mm; }

  .print-slot .sheet-right{ padding:3mm; gap:2mm; }
  .print-slot .tracker-block,.print-slot .downs-block{ padding-bottom:2mm; border-color:#000; }
  .print-slot .tracker-title{ margin-bottom:1.5mm; }
  .print-slot .tracker-grid{ gap:1.5mm; }
  .print-slot .track-box{ border-color:#000; background:#fff; color:#000; }
  .print-slot .counter-button{ display:none; }
  .print-slot .counter-value{ min-width:0; font-size:11pt; color:#000; }
  .print-slot .xp-block input{ font-size:12pt; }

  .print-slot .hab-sheet{
    display:grid;
    grid-template-rows:auto 1fr;
    min-height:0;
  }
  .print-slot .hab-record-heading{
    padding:4mm;
    gap:3mm;
    border-color:#000;
  }
  .print-slot .hab-record-number{ font-size:13pt; }
  .print-slot .hab-sheet-main{ padding:4mm; gap:4mm; }
  .print-slot .hab-top-row{ gap:2mm; }
  .print-slot .hab-top-row input{ padding:1mm; font-size:8pt; }
  .print-slot .hab-block-grid{ gap:2mm; }
  .print-slot .hab-block-slot{
    min-height:28mm;
    padding:2mm;
    border-color:#000;
    background:#fff;
    border-radius:0;
  }
  .print-slot .hab-block-slot input{ min-height:12mm; }
  .print-slot .hab-block-slot.is-unavailable{
    opacity:.45;
    background:#eee;
  }
  .print-slot .hab-block-slot.is-unavailable::before,
  .print-slot .hab-block-slot.is-unavailable::after{ background:#000; }

  .print-slot .gang-sheet-main{ padding:4mm; gap:3mm; }
  .print-slot .gang-section{ padding-bottom:3mm; border-color:#000; }
  .print-slot .resource-grid,.print-slot .hab-grid{ gap:2mm; }
  .print-slot .warehouse-head,.print-slot .warehouse-row{ gap:1.5mm; }
  .print-slot .warehouse-list{ gap:1.2mm; }
  .print-slot .warehouse-row input{ padding:1mm; font-size:7pt; }
}
