/* Pieces that only Rapid Stacker Collab has. Written for this site; colours are tokens from tokens.css. */

/* ----- Layout helpers ----- */
.stack > * + * { margin-top: var(--gap, 18px); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row--between { justify-content: space-between; }
.toolbar { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.num { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }
.panel + .panel { margin-top: 18px; }
.grid > .panel + .panel { margin-top: 0; }
.panel h2, .panel h3 { margin-top: 0; }
.empty { border: 1px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--text-muted); }
.loading { color: var(--text-muted); padding: 18px 0; }
.loading::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading::before { animation: none; } }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.kv dt { color: var(--text-muted); font-size: 14px; }
dl.kv dd { margin: 0; }

/* ----- Theme toggle ----- */
.theme-toggle {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  border-radius: var(--radius-sm); padding: 4px 10px; cursor: pointer; font: inherit; font-size: 13px;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--text); }

/* A button that reads as a nav link (Log out). */
.linklike { background: none; border: none; padding: 0; font: inherit; color: var(--text-muted); cursor: pointer; }
.linklike:hover { color: var(--text); }

/* ----- Segmented control (radio group) -----
   Native radio inputs, visually restyled, so arrow keys and screen readers work with no JS. */
.seg { border: 1px solid var(--border-input); border-radius: 999px; padding: 3px; display: inline-flex; gap: 2px; background: var(--surface-1); margin: 0; min-width: 0; }
.seg legend { padding: 0; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label {
  padding: 7px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px;
  color: var(--text-muted); border: 1px solid transparent; white-space: nowrap;
}
.seg label:hover { color: var(--text); }
.seg input:checked + label { background: var(--primary); color: var(--on-primary); }
.seg input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }
.seg input[value="gold"]:checked + label { background: var(--gold); color: var(--surface-0); }
.seg input:disabled + label { opacity: .5; cursor: not-allowed; }

/* ----- Mode labels: every preview says which stack it shows ----- */
.mode { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; border: 1px solid currentColor; background: var(--surface-1); }
.mode::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mode--live { color: var(--live); }
.mode--gold { color: var(--gold); }
.mode--none { color: var(--text-muted); }

/* ----- Preview frames ----- */
.preview { margin: 0; position: relative; background: var(--preview-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.preview img { width: 100%; height: auto; }
.preview__ph { display: grid; place-items: center; aspect-ratio: 4 / 3; color: var(--preview-text); opacity: .75; text-align: center; padding: 16px; font-size: 14px; }
.preview__badges { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.preview figcaption { padding: 8px 12px; font-size: 13px; color: var(--preview-text); background: rgba(5,6,15,.92); border-top: 1px solid var(--border); }
.preview--adjust img { filter: var(--adjust, none); }

/* ----- Project cards (directory) ----- */
.project-card { display: flex; flex-direction: column; gap: 12px; color: var(--text); border-bottom: 1px solid var(--border); padding: 0; overflow: hidden; }
.project-card:hover { color: var(--text); }
.project-card .preview { border: none; border-radius: 0; }
.project-card__body { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 8px; }
.project-card__title { font-size: 20px; margin: 0; }
.project-card__meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-muted); font-size: 14px; }
.project-card__meta strong { color: var(--text); font-family: var(--font-mono); font-weight: 400; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ----- Per-filter stream cards ----- */
.stream-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.stream-card .preview { border: none; border-radius: 0; }
.stream-card__body { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.stream-card__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stream-card__head h3 { margin: 0; font-size: 18px; }
.stream-card dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 13.5px; }
.stream-card dt { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stream-card dd { margin: 0; font-family: var(--font-mono); }

/* ----- Leaderboard ----- */
.leader { width: 100%; border-collapse: collapse; font-size: 15px; }
.leader th, .leader td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.leader th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.leader td.num, .leader th.num { text-align: right; white-space: nowrap; }
.leader .rank { width: 44px; color: var(--text-muted); font-family: var(--font-mono); }
.meter { display: block; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.meter > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

/* ----- Progress scrubber ----- */
.scrub { display: grid; gap: 12px; }
.scrub input[type="range"] { width: 100%; accent-color: var(--primary); height: 28px; }
.scrub__meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--text-muted); }
.scrub__meta strong { color: var(--text); font-family: var(--font-mono); font-weight: 400; }

/* ----- Activity feed ----- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 92px 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.feed time { color: var(--text-muted); font-size: 13px; font-family: var(--font-mono); }
@media (max-width: 560px) { .feed li { grid-template-columns: 1fr; gap: 2px; } }

/* ----- Charts (js/svg-charts.js). Colours arrive as inline style custom properties. ----- */
.chart { width: 100%; height: auto; color: var(--text); overflow: hidden; }
.chart text { fill: currentColor; font-family: var(--font-prop); font-size: 12px; }
.chart .chart__muted { fill: var(--text-muted); }
.chart .chart__value { font-family: var(--font-mono); font-size: 11.5px; }
.chart__axis { stroke: var(--border); stroke-width: 1; }
.chart__grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; opacity: .7; }
.chart__bar { fill: var(--c, var(--primary)); }
.chart__line { fill: none; stroke: var(--c, var(--primary)); stroke-width: 2; }
.chart__area { fill: var(--c, var(--primary)); opacity: .16; }
.chart__marker { fill: var(--c, var(--gold)); stroke: var(--surface-0); stroke-width: 1.5; }
.chart__cursor { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-muted); margin: 6px 0 0; padding: 0; list-style: none; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; background: var(--c); }

/* ----- Frames table (dashboard) ----- */
.table-scroll { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.table-scroll .data-table { min-width: 760px; }

/* ----- Secret reveal (new API token) ----- */
.secret { font-family: var(--font-mono); word-break: break-all; background: var(--surface-1); border: 1px dashed var(--warning); border-radius: var(--radius-sm); padding: 12px 14px; user-select: all; }

/* ----- Drop zone / misc ----- */
.code-input { font-family: var(--font-mono); font-size: 22px; letter-spacing: .16em; text-transform: uppercase; text-align: center; }

/* ----- Tabs (js/components/tabs.js). Native buttons; the selected one carries aria-selected. ----- */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin: 18px 0 24px; }
.tabs [role="tab"] {
  background: none; border: 0; border-bottom: 3px solid transparent; color: var(--text-muted); padding: 10px 16px; margin-bottom: -1px;
  font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tabs [role="tab"]:hover { color: var(--text); background: var(--surface-1); }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }
.tabs [role="tab"]:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.tabpanel > h2:first-child { margin-top: 0; }
.tabpanel:focus { outline: none; }

/* ----- Confirmation dialog (js/components/dialog.js) ----- */
dialog.modal {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0; width: min(580px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
}
dialog.modal::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
.modal__form { padding: 24px; display: block; }
.modal__title { margin: 0 0 12px; font-size: 22px; }
.modal__body > :first-child { margin-top: 0; }
.modal__body fieldset { margin-top: 12px; }
.modal__body .form__check + .form__check { margin-top: 8px; }

/* A row header in a data table is the member's name, not a column heading: keep it readable. */
.data-table tbody th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); font-weight: 600; }

/* ----- Project frame editor (js/console/frame.js) ----- */
.frame-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .frame-grid { grid-template-columns: minmax(0, 1fr); } }
.sky { width: 100%; aspect-ratio: 4 / 3; min-height: 280px; background: var(--preview-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; position: relative; }
.sky__note { padding: 16px; color: var(--preview-text); font-size: 14px; }
.sketch { width: 100%; max-width: 320px; height: auto; display: block; margin: 0 auto; }
.sketch__frame { fill: color-mix(in srgb, var(--primary) 18%, transparent); stroke: var(--primary); stroke-width: 2; }
.sketch__up { stroke: var(--gold); stroke-width: 2; stroke-dasharray: 4 3; }
.sketch__dot { fill: var(--gold); }
.sketch__arrow { stroke: var(--text-muted); stroke-width: 1.5; }
.sketch__label { fill: var(--text-muted); font: 600 12px var(--font-prop); }
.field-note { font-size: 13px; color: var(--text-muted); }
.is-invalid { border-color: var(--error) !important; }
.sanity--error { border-left: 4px solid var(--error); }
.sanity--warn { border-left: 4px solid var(--warning); }
.field-error { color: var(--error); font-size: 13px; min-height: 0; }
.field-error:empty { display: none; }

/* Form controls the hub's form CSS does not list (url, search) look like the others. */
.form input[type="url"], .form input[type="search"] {
  flex: 1 1 240px; background: var(--surface-1); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 10px; padding: 12px 14px; font: inherit;
}
.form input[type="url"]:focus, .form input[type="search"]:focus { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: 1px; }
.form__row input[type="url"], .form__row input[type="search"] { flex: 0 0 auto; width: 100%; }

/* A button with a long label wraps instead of widening the page on a phone. */
.btn { max-width: 100%; white-space: normal; text-align: center; }

/* ----- Browser uploader (js/pages/upload.js) ----- */
.dropzone { margin: 20px 0; padding: 32px 20px; text-align: center; border: 2px dashed var(--border-input); border-radius: var(--radius); background: var(--surface-1); }
.dropzone.is-over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--surface-1)); }
.dropzone input:focus-visible + label { outline: 3px solid var(--text); outline-offset: 3px; }
.dropzone__hint { margin: 12px 0 0; color: var(--text-muted); }
.upfiles { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; }
.upfile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.upfile--ok { border-left: 4px solid var(--success); }
.upfile--warn { border-left: 4px solid var(--warning); }
.upfile--err { border-left: 4px solid var(--error); }
.upfile--info { border-left: 4px solid var(--live); }
.upfile__head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.upfile__name { font-weight: 600; word-break: break-all; }
.upfile__info { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }
.upfile__loc { margin-top: 10px; padding: 10px 12px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; }
.upfile__loc p { margin: 0 0 6px; }
.upfile__loc > :last-child { margin-bottom: 0; }
.upfile progress { width: 100%; height: 10px; margin-top: 10px; accent-color: var(--primary); }
.upfile__status { margin: 6px 0 0; font-size: 14px; }
