/* Standalone stylesheet for /poker-chips/ - same isolation
   discipline as /astronomy/style.css and
   /molecules/style.css (own file, not shared/imported),
   same token values chosen to match the main site by eye. */

:root {
  --color-bg: #f7f7f5;
  --color-surface: #ffffff;
  --color-border: #cfcfcb;
  --color-text-primary: #0a0a0a;
  --color-text-secondary: #555555;
  --color-text-tertiary: #737373;
  --color-accent: #2f6fed;
  --color-success: #1f9d55;
  --color-error: #c9432f;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #17181a;
    --color-surface: #1e2022;
    --color-border: #35383b;
    --color-text-primary: #ece9e4;
    --color-text-secondary: #a6a49f;
    --color-text-tertiary: #79776f;
    --color-accent: #5b8cff;
    --color-success: #4bcf8a;
    --color-error: #e2776a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  line-height: 1.55;
}

.masthead {
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 24px 28px;
}

.wordmark {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text-secondary);
  text-decoration: none;
  margin-bottom: 24px;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  font-weight: 600;
  margin: 0 0 10px;
}

.masthead h1 {
  font-size: clamp(1.7rem, 4.5vw, 2.3rem);
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.dek {
  color: var(--color-text-secondary);
  font-size: 1rem;
  margin: 0;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 20px;
}

.field-row {
  margin-bottom: 18px;
}

.field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.style-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 14.5px;
  color: var(--color-text-primary);
  cursor: pointer;
  padding: 9px 0;
}

.style-toggle input {
  margin: 0;
  cursor: pointer;
}

input[type="text"],
input[type="email"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
}

.panel-title {
  font-size: 1.05rem;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.panel-subtitle {
  color: var(--color-text-secondary);
  font-size: 13.5px;
  margin: 0 0 18px;
}

.sync-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 14px;
}

.sync-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.sync-toggle input {
  margin: 0;
  cursor: pointer;
}

.table-scroll {
  overflow-x: auto;
  margin-bottom: 18px;
}

.chip-table {
  border-collapse: collapse;
  width: 100%;
}

.chip-table th,
.chip-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--color-border);
}

.chip-table thead th {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
  font-weight: 600;
}

.chip-table tbody tr:last-child td {
  border-bottom: none;
}

.chip-table td:first-child {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text-tertiary);
  width: 20px;
}

/* Widths reflect real content, not equal shares - a denomination
   ("$500") needs far less room than a phrase ("HAPPY BIRTHDAY"), and
   giving front text the same min-width as back text was itself part
   of why the table forced horizontal scroll on a phone-width screen. */
.chip-table select,
.chip-table input[type="text"] {
  width: 100%;
  padding: 7px 8px;
  font-size: 14px;
}

.chip-table .color-cell select {
  min-width: 76px;
}

.chip-table .front-text-cell input {
  min-width: 52px;
}

.chip-table .back-text-cell input {
  min-width: 84px;
}

.chip-table input[type="text"]:disabled {
  background: var(--color-bg);
  color: var(--color-text-tertiary);
  cursor: not-allowed;
}

/* Below phone width, the table can't show four real columns without
   scrolling no matter how tight the widths get - so it stops being a
   table (visually) and becomes one labeled block per chip instead.
   Standard "responsive data table" pattern: each td's own data-label
   supplies the field name that the (now-hidden) header would have. */
@media (max-width: 520px) {
  .table-scroll { overflow-x: visible; }

  .chip-table, .chip-table tbody, .chip-table tr, .chip-table td {
    display: block;
    width: 100%;
  }

  .chip-table thead { display: none; }

  .chip-table tbody tr {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }

  .chip-table tbody tr:last-child { margin-bottom: 0; }

  .chip-table td {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    border-bottom: none;
  }

  .chip-table td::before {
    content: attr(data-label);
    flex: 0 0 72px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-text-tertiary);
  }

  .chip-table td:first-child {
    width: 100%;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
  }

  .chip-table td:first-child::before {
    content: "Chip";
    font-weight: 400;
  }

  .chip-table select,
  .chip-table input[type="text"] {
    min-width: 0;
  }
}

/* #chip-rows accordion - the personalized chip set ONLY (scoped to
   #chip-rows, never the shared .chip-table, so #bulk-panel's own
   #batch-rows keeps the plain stacked-card behavior above on every
   viewport). Stacking all 5 chips' fields at once, below the style
   toggles + three color pickers + sync toggles, made the phone-width
   form a long scroll-and-type before any result - so below the
   breakpoint each chip collapses to one tappable summary line (its
   number, body color, and whatever message is already entered - live
   values, see app.js's own refreshChipSummaries), with only one chip's
   fields open at a time (see app.js's own toggleChipRow). The summary
   button is display:none on desktop and .chip-row--expanded has no
   effect there, so the desktop table is exactly as before. */
#chip-rows .chip-accordion-toggle {
  display: none;
}

@media (max-width: 520px) {
  /* The plain "1" the desktop Chip column shows gives way to the
     summary button, which carries the chip number itself. */
  #chip-rows .chip-index { display: none; }

  #chip-rows td:first-child {
    padding: 0;
  }

  /* The shared rule above labels this cell "Chip" via ::before - the
     summary button already says "Chip N", so no separate label here. */
  #chip-rows td:first-child::before { content: none; }

  #chip-rows .chip-accordion-toggle {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    min-height: 44px;
    padding: 6px 0;
    border: none;
    background: transparent;
    color: var(--color-text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
  }

  #chip-rows .chip-summary-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
  }

  #chip-rows .chip-summary-color {
    font-weight: 400;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #chip-rows .chip-summary-chevron {
    flex: 0 0 auto;
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-right: 1.5px solid var(--color-text-tertiary);
    border-bottom: 1.5px solid var(--color-text-tertiary);
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
  }

  #chip-rows tr.chip-row--expanded .chip-summary-chevron {
    transform: rotate(45deg);
  }

  #chip-rows .chip-summary-preview {
    display: block;
    max-width: 100%;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #chip-rows .chip-summary-preview--empty {
    color: var(--color-text-tertiary);
    font-style: italic;
  }

  /* Collapsed: just the summary line, in a tighter card. The inputs
     stay in the DOM with their values (only hidden), so app.js's
     collectCurrentChips/applySyncForField read them exactly as before. */
  #chip-rows tr:not(.chip-row--expanded) {
    padding: 4px 12px;
  }

  #chip-rows tr:not(.chip-row--expanded) td.color-cell,
  #chip-rows tr:not(.chip-row--expanded) td.front-text-cell,
  #chip-rows tr:not(.chip-row--expanded) td.back-text-cell {
    display: none;
  }

  /* Expanded: a hairline between the (still tappable) header and the
     fields it opened. */
  #chip-rows tr.chip-row--expanded td:first-child {
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 6px;
  }
}

/* One slide of the swipeable carousel below - flex-basis 100% of the
   track's own width, so exactly one chip is visible/snapped at a time
   no matter how many chips are in the set. */
#results-container.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  /* Position communicated via the dots below, not a visible scrollbar -
     same "own overflow-x:auto container" pattern as .table-scroll, just
     with the browser chrome hidden since swipe + dots already show it. */
  scrollbar-width: none;
}

#results-container.carousel-track::-webkit-scrollbar {
  display: none;
}

.result-card {
  flex: 0 0 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 22px 24px;
}

.color-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.color-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
}

.color-pill.active {
  background: var(--color-text-primary);
  color: var(--color-bg);
  border-color: var(--color-text-primary);
}

.carousel-caption {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin: 0 0 10px;
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 24px;
}

.carousel-dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-border);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.carousel-dot.active {
  background: var(--color-accent);
  transform: scale(1.4);
}

.result-card-title {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* .btn's own `display` declaration is an author rule, so it beats the
   UA stylesheet's [hidden]{display:none} on specificity ties (author
   always wins over UA regardless of specificity) - the same real bug
   this file's own .feedback-text[hidden] rule below already works
   around. Kept as general-purpose defensive CSS for any button a future
   change hides via the `hidden` attribute. */
.btn[hidden] { display: none; }

/* Bulk pack size picker - a row of selectable pills (real radio inputs
   underneath, for accessibility/keyboard support), not a <select> - the
   4 real, fixed pack sizes are few enough to show all at once with their
   own price alongside, matching the site's existing pill-style patterns
   (see .color-pill in the results section below). */
.pack-size-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pack-size-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text-primary);
  cursor: pointer;
}

.pack-size-option input {
  margin: 0;
  cursor: pointer;
}

.pack-size-option:has(input:checked) {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
}

.btn-primary {
  background: var(--color-text-primary);
  color: var(--color-bg);
}

.btn-secondary {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

.btn-block { width: 100%; }

.feedback-text {
  min-height: 16px;
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--color-text-secondary);
}

.feedback-text.error { color: var(--color-error); }
.feedback-text.success { color: var(--color-success); }
.feedback-text[hidden] { display: none; }

.result-summary {
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--color-text-secondary);
  margin: 0 0 6px;
}

.engraved-note {
  font-size: 12.5px;
  color: var(--color-text-tertiary);
  margin: 8px 0 0;
}

.model-viewer-el {
  width: 100%;
  height: 320px;
  --poster-color: transparent;
  display: block;
  margin-bottom: 16px;
  border-radius: 8px;
  background: var(--color-bg);
}

.site-foot {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 24px 56px;
  border-top: 1px solid var(--color-border);
  font-size: 12.5px;
  color: var(--color-text-tertiary);
}

.site-foot a { color: var(--color-text-secondary); }

/* Bundled tube+cap note, inline with the personalized-chip form. */
.bundled-note {
  font-size: 12.5px;
  color: var(--color-text-tertiary);
  margin: -4px 0 14px;
}

/* Bulk denomination batches panel - reuses .chip-table's own styling
   (same responsive stacked-card behavior below 520px) plus a narrower
   quantity column and a per-row remove button. */
#bulk-panel .chip-table .qty-cell input[type="number"] {
  width: 100%;
  padding: 7px 8px;
  font-size: 14px;
  min-width: 56px;
}

#bulk-panel .chip-table .remove-cell {
  width: 32px;
}

.batch-remove-button {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-tertiary);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.batch-remove-button:hover {
  color: var(--color-error);
  border-color: var(--color-error);
}

#add-batch-button {
  margin-top: 4px;
}

.results-subheading {
  margin: 28px 0 12px;
}

#tube-result-wrap .result-card { margin-bottom: 20px; }

@media (max-width: 520px) {
  #bulk-panel .chip-table td::before { content: attr(data-label); }
  #bulk-panel .chip-table .remove-cell::before { content: ""; flex: 0; }
  #bulk-panel .chip-table .remove-cell { justify-content: flex-end; }
}
