/* Ribbon + account-widget styling lives in /site/nav.css, shared with the site pages. @import leads. */
@import url('/site/nav.css');

/* Self-hosted EB Garamond, served same-origin from /fonts — no external font CDN. Two variable faces,
   each spanning weight 400–800 (so bold, 700, needs no separate file): upright and true italic. */
@font-face {
  font-family: 'EB Garamond';
  src: url('/fonts/EBGaramond.ttf') format('truetype');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('/fonts/EBGaramond-Italic.ttf') format('truetype');
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #f6f4ee;
  --paper-2: #ffffff; /* white surfaces in the shared nav (pill, dropdown) */
  --panel: #fbfaf6;
  --panel-2: #f0ede4;
  --field: #ffffff;
  --canvas: #ecebe3;
  --ink: #1b1a17;
  --muted: #6f6a60;
  --line: #e0dccf;
  --line-strong: #cfc9b8;
  --accent: #9c2b2b;
  --accent-ink: #7a1f1f;
  --accent-soft: #cfa6a6;
  --selected: #f3e6e2;
  --focus: rgba(156, 43, 43, 0.18);
  --serif: 'EB Garamond', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --card-w: 250px;
  --card-h: 350px;
  --clan-dynasty: #efe2d2;
  --clan-dynasty-ink: #8a5a2b;
  --clan-fate: #dfe7ec;
  --clan-fate-ink: #3a5a6e;
  --clan-pre: #e2ead8;
  --clan-pre-ink: #4a5e2a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none; }
/* Reserve the scrollbar gutter so the ribbon lines up with the scrolling site pages, which lose
   width to their document scrollbar; this page never scrolls (body is overflow: hidden). */
html { scrollbar-gutter: stable; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.col-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.counts {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

.columns {
  display: grid;
  grid-template-columns: 1fr 4px 1fr 4px 453px;
  height: calc(100vh - 53px);
  gap: 0;
  background: var(--line);
}
.col {
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.gutter {
  background: var(--line-strong);
  cursor: col-resize;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
}
.gutter:hover, .gutter.dragging {
  background: var(--accent);
}
.col-header {
  background: var(--panel-2);
  padding: 9px 14px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.deck-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.deck-header-actions {
  display: flex;
  gap: 4px;
}
.btn-small {
  background: var(--field);
  color: var(--accent-ink);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--sans);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-small:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-small.btn-danger { color: var(--accent); border-color: var(--accent-soft); }

.account-status {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--sans);
  padding: 4px 2px 0;
}

.my-decks-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 2px;
  max-height: 220px;
  overflow-y: auto;
}
.my-decks-row { display: flex; gap: 4px; }
.my-decks-row .btn-small:first-child { flex: 1; text-align: left; }
.my-decks-empty { font-size: 0.75rem; color: var(--muted); font-family: var(--sans); margin: 0; }
.deck-name-row {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
#deckNameInput { flex: 1; }
#deckAuthorInput { flex: 0 0 34%; }
.deck-name-row input {
  width: 100%;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 5px 8px;
  font-size: 0.83rem;
  font-family: var(--sans);
}
.deck-name-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus);
}
.deck-name-row.shake input {
  border-color: #c33;
  box-shadow: 0 0 0 2px rgba(204, 51, 51, 0.25);
}
.deck-name-row.shake {
  animation: shake 0.4s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* Search & Filters */
.filters {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.filters input, .filters select {
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 7px 10px;
  font-size: 0.85rem;
  font-family: var(--sans);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filters input:focus, .filters select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus);
}
.filters input::placeholder { color: var(--muted); font-style: italic; }
.search-row {
  display: flex;
  gap: 6px;
}
.search-row input { flex: 1; }
.filter-row {
  display: flex;
  gap: 6px;
}
.filter-row select { flex: 1; }
.help-btn {
  background: var(--field);
  color: var(--accent-ink);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  align-self: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.help-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.search-help {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.help-content {
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
}
.help-content b { color: var(--accent-ink); }
.help-content code {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 0.75rem;
  color: var(--accent-ink);
}

/* Card List */
.card-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}
.card-list-item {
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.card-list-item:hover {
  background: var(--panel-2);
  border-left-color: var(--accent-soft);
}
.card-list-item.selected {
  background: var(--selected);
  border-left-color: var(--accent);
}
.card-list-item .side-tag {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 2px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--sans);
}
.side-tag.dynasty { background: var(--clan-dynasty); color: var(--clan-dynasty-ink); }
.side-tag.fate { background: var(--clan-fate); color: var(--clan-fate-ink); }
.side-tag.pre_game { background: var(--clan-pre); color: var(--clan-pre-ink); }

/* Deck panel */
.deck-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
#dynastySection { flex: 5; }
#fateSection { flex: 5; }
#preGameSection { flex: 2; }
.deck-gutter {
  height: 4px;
  background: var(--line-strong);
  cursor: row-resize;
  flex-shrink: 0;
  transition: background 0.15s;
}
.deck-gutter:hover, .deck-gutter.dragging {
  background: var(--accent);
}
.deck-section-header {
  padding: 7px 12px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--panel-2);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.deck-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}
.deck-item {
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.83rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border-left: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.deck-item:hover {
  background: var(--panel-2);
  border-left-color: var(--accent-soft);
}
.deck-item.selected {
  background: var(--selected);
  border-left-color: var(--accent);
}
.deck-item .qty {
  background: var(--accent);
  color: #fff;
  padding: 1px 7px;
  border-radius: 2px;
  font-size: 0.75rem;
  min-width: 22px;
  text-align: center;
  font-weight: 700;
  font-family: var(--sans);
  margin-right: 8px;
  flex-shrink: 0;
}
.deck-type-header {
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 6px;
  font-family: var(--sans);
}
.deck-type-header:first-child { margin-top: 0; }
.deck-sub-item {
  padding: 3px 10px 3px 32px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border-left: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.deck-sub-item:hover {
  background: var(--panel-2);
  border-left-color: var(--accent-soft);
}
.deck-sub-item.selected {
  background: var(--selected);
  border-left-color: var(--accent);
  color: var(--ink);
}
.deck-sub-item .qty {
  background: var(--line-strong);
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 0.7rem;
  min-width: 20px;
  text-align: center;
  font-weight: 700;
  font-family: var(--sans);
  margin-right: 8px;
  flex-shrink: 0;
}
.print-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
}
.print-nav button {
  background: var(--field);
  color: var(--accent-ink);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  width: 32px;
  height: 28px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--sans);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.print-nav button:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.print-nav button:disabled { opacity: 0.35; cursor: default; }
.print-nav .print-info {
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 140px;
  text-align: center;
}
.preview-flavor {
  width: 100%;
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.6;
  font-style: italic;
  color: var(--muted);
  padding: 10px 12px;
  background: var(--panel);
  border-radius: 4px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.deck-actions {
  padding: 8px;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.btn {
  background: var(--field);
  color: var(--accent-ink);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--sans);
  flex: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-danger { border-color: #d9b3b3; color: var(--accent); }
.btn-danger:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Preview */
.preview {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--canvas);
}
.preview-img {
  width: 429px;
  height: 600px;
  object-fit: contain;
  border-radius: 4px;
  background: var(--field);
  flex-shrink: 0;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.18);
  transition: transform 0.3s ease;
}
.preview-placeholder {
  width: 429px;
  height: 600px;
  background: var(--field);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
}
.preview-stats {
  width: 100%;
  font-size: 0.85rem;
}
.preview-stats table {
  width: 100%;
  border-collapse: collapse;
}
.preview-stats td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.preview-stats td:first-child {
  color: var(--muted);
  width: 40%;
  font-style: italic;
}
.preview-name {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  text-align: center;
  width: 100%;
  color: var(--accent-ink);
}
.preview-rules {
  width: 100%;
  font-size: 0.83rem;
  line-height: 1.6;
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-wrap: break-word;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}
.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 20px;
  font-size: 0.85rem;
  font-style: italic;
}

/* ── Borrow-art modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 26, 23, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  width: min(860px, 92vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.modal-head {
  padding: 12px 16px;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-ink);
  border-bottom: 1px solid var(--line);
}
.modal-body {
  display: flex;
  gap: 16px;
  padding: 16px;
  overflow: hidden;
}
.borrow-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.borrow-left input {
  width: 100%;
  padding: 8px;
  background: var(--field);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  border-radius: 4px;
  margin-bottom: 8px;
  font-family: var(--sans);
}
.borrow-results {
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  max-height: 52vh;
}
.borrow-result {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.borrow-result:hover { background: var(--panel-2); }
.borrow-result.selected { background: var(--accent); color: #fff; }
.borrow-right {
  flex: 0 0 270px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.borrow-preview-wrap {
  position: relative;
  width: 252px;
  height: 357px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.borrow-preview { max-width: 100%; max-height: 100%; display: block; }
.borrow-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
  padding: 12px;
}
.borrow-print-nav { margin-top: 8px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.deck-item.custom > span:last-child,
.deck-sub-item.custom > span:last-child { color: var(--accent-ink); font-style: italic; }

/* Print sheet: built off-screen so its images load, then swapped in as the only visible content
   when printing. Cards print at actual size (63.5 x 90 mm), 8 per landscape Letter page, in a
   centered 4-wide grid with a 3 mm gutter between cards to cut along for proxies. */
#printSheet {
  position: absolute;
  left: -10000px;
  top: 0;
}
.print-page {
  display: grid;
  grid-template-columns: repeat(4, 63.5mm);
  grid-auto-rows: 90mm;
  gap: 3mm;
  justify-content: center;
  align-content: center;
}
.print-card {
  width: 63.5mm;
  height: 90mm;
  object-fit: fill;
  display: block;
}

@media print {
  @page {
    size: letter landscape;
    margin: 6mm;
  }
  body > *:not(#printSheet) {
    display: none !important;
  }
  #printSheet {
    position: static;
    left: auto;
  }
  .print-page {
    break-after: page;
    break-inside: avoid;
  }
  .print-page:last-child {
    break-after: auto;
  }
}
