/* Tournament Planner (Easy Mode) — page styles.
   Extends the HPI design tokens in ../hpi.css; no new colour/spacing systems.
   Tool-specific layout only. */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
/* The hidden attribute must always win over our display:flex/grid rules
   (saved-set wrap, output view, insufficient panel, QR, toast). */
[hidden] { display: none !important; }

.tp-block { margin-bottom: var(--space-lg); }
.tp-h2 {
  font-family: var(--font-heading); font-weight: 600;
  font-size: 1.15rem; margin: 0 0 var(--space-md);
  color: var(--color-text-heading);
}

/* ---------- Preset selector ---------- */
.preset-grid {
  border: 0; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md);
}
@media (max-width: 560px) { .preset-grid { grid-template-columns: 1fr; } }

.preset-card { position: relative; display: block; cursor: pointer; }
.preset-card input {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.preset-card-inner {
  display: block; height: 100%;
  padding: var(--space-md);
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: var(--glass-radius);
  transition: border-color .15s, background .15s, transform .05s;
}
.preset-card:hover .preset-card-inner { border-color: var(--glass-border-strong); }
.preset-card input:focus-visible + .preset-card-inner { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.preset-card input:checked + .preset-card-inner {
  border-color: var(--color-accent);
  background: var(--color-accent-faint);
}
.preset-name {
  display: block; font-family: var(--font-heading); font-weight: 700;
  font-size: 1.2rem; color: var(--color-text-heading);
}
.preset-time { display: block; color: var(--color-accent); font-size: .9rem; margin: 2px 0 var(--space-sm); }
.preset-desc { display: block; color: var(--color-text-muted); font-size: .9rem; line-height: 1.4; }

/* ---------- Fields ---------- */
.tp-field { margin-bottom: var(--space-md); }
.tp-field label { display: block; font-weight: 700; margin-bottom: var(--space-xs); }
.tp-field input {
  width: 100%; box-sizing: border-box;
  padding: 12px 14px; font-size: 1rem; font-family: var(--font-body);
  color: var(--color-text); background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border); border-radius: 8px;
}
.tp-field input:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.tp-field-inline { display: flex; align-items: center; gap: var(--space-md); }
.tp-field-inline label { margin: 0; }
.tp-field-inline input { max-width: 140px; }
.tp-hint { color: var(--color-text-muted); font-size: .85rem; margin: var(--space-xs) 0 0; }

.tp-details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-md); margin-top: var(--space-md); }
@media (max-width: 560px) { .tp-details-grid { grid-template-columns: 1fr; } }

/* Players + Buy-in side by side, mirroring the preset cards' 2-column grid */
.tp-players-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.tp-players-grid .tp-field { margin-bottom: 0; }
@media (max-width: 560px) { .tp-players-grid { grid-template-columns: 1fr; gap: var(--space-md); } }
.tp-summary { cursor: pointer; font-family: var(--font-heading); font-weight: 600; color: var(--color-text-heading); }

/* ---------- Chip rows ---------- */
.chip-rows { display: flex; flex-direction: column; gap: var(--space-sm); }
.chip-row {
  display: grid; grid-template-columns: 80px 1fr 110px auto auto; gap: var(--space-sm);
  align-items: center;
}
.chip-row input[type="number"], .chip-row input[type="text"] {
  width: 100%; box-sizing: border-box; padding: 10px;
  color: var(--color-text); background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border); border-radius: 8px;
}
.chip-row .chip-swatch {
  width: 18px; height: 18px; border-radius: 50%; display: inline-block;
  border: 1px solid rgba(255,255,255,0.4); vertical-align: middle; margin-right: 6px;
}
.chip-color-cell { display: flex; align-items: center; }
.chip-color-cell input { flex: 1; }
.ncv-toggle { display: flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--color-text-muted); white-space: nowrap; }
.chip-remove {
  background: none; border: 1px solid var(--glass-border); color: var(--color-text);
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.chip-remove:hover { border-color: var(--color-accent); color: var(--color-accent); }
.chip-remove:disabled { opacity: .35; cursor: default; }
.tp-add-row { margin-top: var(--space-sm); }
.tp-savedset { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-md); flex-wrap: wrap; }
.tp-savedset label { font-weight: 700; }
.tp-savedset select {
  padding: 10px 12px; font-size: 1rem; font-family: var(--font-body);
  color: var(--color-text); background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border); border-radius: 8px;
}
.tp-savedset select:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }

@media (max-width: 560px) {
  .chip-row { grid-template-columns: 1fr 1fr; gap: var(--space-xs) var(--space-sm); padding: var(--space-sm); background: rgba(0,0,0,0.18); border-radius: 8px; }
  .chip-row .chip-color-cell { grid-column: 1 / -1; }
}

/* ---------- Plan button + validation ---------- */
.tp-plan-btn { width: 100%; font-size: 1.15rem; padding: 16px; }
.tp-validation {
  color: #ffd9d2; background: rgba(192,57,43,0.25); border: 1px solid rgba(192,57,43,0.6);
  padding: 12px 14px; border-radius: 8px; margin-bottom: var(--space-md);
}

/* ---------- Output ---------- */
.tp-summary-block { text-align: center; }
.tp-summary-title { font-family: var(--font-heading); font-weight: 700; font-size: 1.6rem; color: var(--color-text-heading); margin: 0 0 var(--space-xs); }
.tp-summary-meta { color: var(--color-text-muted); display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-lg); justify-content: center; }
.tp-summary-meta strong { color: var(--color-text); }
.tp-summary-duration { margin-top: var(--space-md); font-size: 1.1rem; color: var(--color-accent); }

.tp-output-section h2 { font-family: var(--font-heading); font-weight: 600; font-size: 1.25rem; color: var(--color-text-heading); margin: 0 0 var(--space-md); }

.tp-table { width: 100%; border-collapse: collapse; }
.tp-table th, .tp-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--glass-border); }
.tp-table th { font-family: var(--font-heading); font-weight: 600; color: var(--color-accent); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.tp-table td.num, .tp-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tp-table tr.tp-total td { font-weight: 700; border-top: 2px solid var(--glass-border-strong); border-bottom: 0; }
.tp-table tr.break-row td { color: var(--color-accent); background: var(--color-accent-subtle); font-style: italic; }
.tp-colorup-note { color: var(--color-accent); font-size: .85rem; }

.tp-rebuy-note { margin: var(--space-md) 0 0; padding: 10px 14px; font-size: .85rem; color: var(--color-text-muted); line-height: 1.5; background: var(--color-accent-subtle); border-left: 3px solid var(--color-accent-dim); border-radius: 6px; }
.tp-rebuy-note a { color: var(--color-accent); }
.tp-finetune { display: inline-block; margin-top: var(--space-md); color: var(--color-accent); text-decoration: none; font-weight: 700; font-size: .9rem; }
.tp-finetune:hover { text-decoration: underline; }

.tp-swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid rgba(255,255,255,0.4); vertical-align: middle; margin-right: 8px; }

/* Host tips */
.tp-tip { margin-bottom: var(--space-md); }
.tp-tip h3 { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; color: var(--color-text-heading); margin: 0 0 4px; }
.tp-tip p { margin: 0; color: var(--color-text-muted); line-height: 1.5; }
.tp-tip a { color: var(--color-accent); }

/* Insufficient panel */
.tp-insufficient h2 { color: #ffd9d2; }
.tp-insufficient h3 { font-family: var(--font-heading); font-weight: 600; font-size: 1.05rem; color: var(--color-text-heading); margin: var(--space-lg) 0 var(--space-sm); }
.tp-insufficient ul { margin: var(--space-sm) 0; }
.tp-insufficient ol { margin: var(--space-sm) 0; padding-left: 1.4em; }
.tp-insufficient li { margin-bottom: var(--space-xs); line-height: 1.5; }
.tp-insufficient .tp-row-short td { color: #ffd9d2; }

/* Actions / toast / QR */
.tp-actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-lg); }
.tp-qr { margin-top: var(--space-md); text-align: center; }
.tp-qr img, .tp-qr canvas, .tp-qr svg { background: #fff; padding: 12px; border-radius: 8px; }
.tp-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: #fff; padding: 12px 20px; border-radius: 8px;
  border: 1px solid var(--color-accent); z-index: 9999;
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff !important; color: #000; }
  .site-header, .site-footer, #formView, .tp-actions, .tp-qr, .back-link, .tp-finetune, .nav-toggle { display: none !important; }
  .glass-panel { background: #fff !important; border: 1px solid #ccc !important; box-shadow: none !important; backdrop-filter: none !important; }
  .tp-h2, .tp-output-section h2, .tp-summary-title, .preset-name { color: #000 !important; }
  .tp-table th { color: #000 !important; }
  .tp-table th, .tp-table td { border-color: #999 !important; }
  .tp-summary-meta, .tp-tip p, .tp-hint { color: #333 !important; }
  .tp-summary-duration, .tp-colorup-note { color: #000 !important; }
  main, .container { max-width: 100% !important; }
  .tp-block { margin-bottom: 14px; box-shadow: none; }
  .tp-output-section, .tp-summary-block, .tp-tip, .tp-table tr { break-inside: avoid; }
  .tp-table th, .tp-table td { padding: 4px 8px; }
  a[href]::after { content: ""; } /* no URL footnotes */
  @page { margin: 1.4cm; }
}

/* Shown until the module initializes; if it never does (opened as a file://
   instead of served over http, or JS disabled), this stays visible so the
   failure isn't silent. */
.tp-loadwarn {
  background: rgba(192,57,43,0.25); border: 1px solid rgba(192,57,43,0.6);
  color: #ffd9d2; padding: 12px 14px; border-radius: 8px; margin-bottom: var(--space-lg);
}
