/* =============================================================================
 * pool3d.css — what the 3D page adds on top of pool.css.
 *
 * pool.css owns every token, card, button, dial and sheet. This file only
 * covers the things the 2D page does not have: a canvas that fills its box
 * instead of keeping the table's aspect, HTML tags floated over the scene, the
 * camera bar, and the WebGL fallback panel.
 * ========================================================================== */

/* ---- the canvas -------------------------------------------------------- */

/* The wrapper is sized by the layout; the canvas is pinned to it and can
   never feed its own size back (the 2D gotcha about width:auto). */
.table-wrap-3d { position: relative; min-height: 0; }

#table3d {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  border-radius: var(--r-lg);
  touch-action: none;
  cursor: crosshair;
  box-shadow: var(--shadow-2);
  background: var(--ground-2);
  user-select: none; -webkit-user-select: none;
}
#table3d.is-placing { cursor: grab; }
#table3d.is-placing:active { cursor: grabbing; }
#table3d.is-busy { cursor: default; }

/* ---- floating tags ----------------------------------------------------- */

.tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: var(--r-lg); }

.tag3d {
  --accent: var(--ochre);
  position: absolute; left: 0; top: 0;
  font-family: var(--ff-mono); font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 4px 7px; border-radius: 4px; white-space: nowrap;
  background: rgba(8,14,13,.80); color: #F2EEE3;
  border: 1px solid color-mix(in srgb, var(--accent) 75%, transparent);
  will-change: transform;
}
.tag3d-badge {
  width: 22px; height: 22px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px;
  border: 1.5px solid var(--brass);
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}

/* ---- camera bar -------------------------------------------------------- */

.cambar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 0 4px; flex: none;
}
.cambar-label {
  font-family: var(--ff-mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3); margin-right: 4px;
}
.cam-btn {
  appearance: none; cursor: pointer;
  border: 1px solid var(--hair); background: var(--surface);
  color: var(--ink-2); border-radius: 999px;
  padding: 5px 12px; font-size: 12.4px; font-weight: 500;
  transition: background .16s, color .16s, border-color .16s;
}
.cam-btn:hover { color: var(--ink); border-color: var(--hair-2); }
.cam-btn.is-on { background: var(--teal); border-color: var(--teal); color: #fff; box-shadow: var(--shadow-1); }
.cambar-hint {
  margin-left: auto; font-family: var(--ff-mono); font-size: 10.4px;
  letter-spacing: .03em; color: var(--ink-3);
}

/* ---- brand ------------------------------------------------------------- */

.pill-3d {
  display: inline-block; vertical-align: 2px; margin-left: 4px;
  font-family: var(--ff-mono); font-size: 9.5px; font-weight: 600; letter-spacing: .1em;
  padding: 2px 6px; border-radius: 999px;
  background: var(--ochre); color: #fff;
}
.mode-link { text-decoration: none; display: inline-flex; align-items: center; }

/* ---- WebGL fallback ---------------------------------------------------- */

.no-webgl {
  position: absolute; inset: 0;
  display: grid; align-content: center; justify-items: start;
  padding: clamp(18px, 5vw, 40px);
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
}
.no-webgl .kicker {
  font-family: var(--ff-mono); font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ochre); margin: 0 0 8px;
}
.no-webgl h2 {
  font-family: var(--ff-display); font-size: clamp(20px, 3vw, 27px); font-weight: 700;
  margin: 0 0 8px; letter-spacing: -.015em; line-height: 1.16;
}
.no-webgl p { margin: 0; max-width: 56ch; font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.no-webgl a { color: var(--teal); font-weight: 600; }

/* ---- aiming dims the room, as on the 2D page ---------------------------- */

body.is-aiming.mode-train .panel-left { opacity: .60; }

/* ---- responsive --------------------------------------------------------- */

@media (max-width: 860px) {
  .table-wrap-3d { min-height: 56vh; }
  /* pool.css puts the hint in the flow under 860px, which works when the
     canvas is an in-flow grid item. Here the canvas is absolute, so an
     in-flow hint is the wrapper's only child and lands dead centre over the
     cloth. Keep it pinned to the bottom edge instead. */
  .table-wrap-3d .hint-strip {
    position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
    margin: 0; max-width: calc(100% - 24px); white-space: normal; text-align: center;
  }
  .cambar-hint { display: none; }
  .cambar { justify-content: center; }
  .brand-text strong .pill-3d { vertical-align: 1px; }
}

@media (max-width: 560px) {
  .cam-btn { padding: 6px 10px; font-size: 12px; }
  .table-wrap-3d { min-height: 60vh; }
}

/* ============================================ the 2D redesign's fallout ===
 * v1.6.0 rebuilt the 2D page around "the table is the interface": the stage
 * became a single column, both rails moved behind a hamburger, and the base
 * `.stage` (three columns) and `.panel` (scrolling flex column) rules were
 * DELETED from pool.css.
 *
 * This page still uses that layout. It shares pool.css, so deleting those
 * rules collapsed its canvas wrapper to zero height — and app3d's resize()
 * bails below 40px, so the WebGL backing store stayed at the HTML default
 * 300x150 while CSS stretched it to 1424 wide. Five rendered checks failed
 * (black canvas, no shading, no cloth, no red ball) on a page whose markup
 * and JavaScript were untouched and perfectly valid.
 *
 * The 3D table keeps the reading-room layout deliberately: it has no dock to
 * float, its canvas is absolutely positioned inside .table-wrap-3d, and the
 * camera bar already occupies the space a dock would want. So the rules are
 * restored here, scoped to body.is-3d, in the stylesheet only this page loads.
 *
 * ⚠ pool.css is SHARED. Anything removed from it must be checked against
 * /pool/3d/ before it ships, exactly like the shared engine modules. */

body.is-3d .stage {
  grid-template-columns: var(--panel-w-l) minmax(0, 1fr) var(--panel-w-r);
  gap: 12px;
  padding: 12px;
}

body.is-3d .panel {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding-right: 2px;
  transition: opacity .3s ease;
}

/* The speed bar is an in-flow row here, not the 2D page's floating pill. */
body.is-3d .stroke {
  position: static; transform: none; width: auto; max-width: none;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--r-lg); padding: 9px 12px;
  box-shadow: var(--shadow-1); flex: none; backdrop-filter: none;
}
body.is-3d .stroke-track { height: 26px; border-radius: 6px; }
body.is-3d.is-aiming .stroke { opacity: 1; }

@media (max-width: 1240px) {
  body.is-3d { --panel-w-l: 232px; --panel-w-r: 276px; }
}

/* The left panel is an off-canvas drawer in this band; #btn-panel opens it and
 * pool.css still carries the scrim and the button's display rule. */
@media (max-width: 1080px) {
  body.is-3d .stage { grid-template-columns: minmax(0, 1fr) var(--panel-w-r); }
  body.is-3d .panel-left {
    position: fixed; inset: 56px auto 0 0; width: 272px; z-index: 30;
    background: var(--surface); border-right: 1px solid var(--hair);
    padding: 12px; transform: translateX(-102%);
    transition: transform .3s cubic-bezier(.2,.7,.3,1); box-shadow: var(--shadow-2);
  }
  body.is-3d.left-open .panel-left { transform: none; }
}

/* Phone: one column, table first, then the controls, then the setup. The left
 * panel MUST come out of the drawer here — there is no toggle at this width,
 * and parked at translateX(-102%) the score and "Rack them" are unreachable. */
@media (max-width: 860px) {
  body.is-3d { overflow: auto; }
  body.is-3d .app { height: auto; min-height: 100dvh; }
  body.is-3d .stage { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  body.is-3d .panel { overflow: visible; max-height: none; }
  body.is-3d .panel-left, body.is-3d .panel-right {
    position: static; width: auto; inset: auto; transform: none;
    background: transparent; border-right: 0; box-shadow: none; padding: 0;
  }
  body.is-3d .felt { order: 1; }
  body.is-3d .panel-right { order: 2; }
  body.is-3d .panel-left { order: 3; }
  body.is-3d .felt-inner { min-height: 54vh; }
  body.is-3d .topbar { flex-wrap: wrap; gap: 10px 14px; }
  body.is-3d .brand-text em { display: none; }
  body.is-3d .modes { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  body.is-3d .stroke { flex-wrap: wrap; }
  body.is-3d .stroke-read { min-width: 62px; }
  body.is-3d .btn-shoot { flex: 1 1 100%; }
  body.is-3d .quote-rail { padding: 10px 14px 20px; }
}
