/* tank.tektology.com - the controls page at /settings/.

   Layered on app.css, which owns the app bar, the notched panel, the buttons,
   the toast, AND - since the redesign - the slider and the switch, because
   three places want those now rather than two. This file is what is genuinely
   local: the section rail, the setting blocks, the key-binding grid and the
   sticky action bar.

   No inline styles anywhere - the vhost sends a strict CSP with no
   'unsafe-inline'. That includes the slider: its fill is a track colour and a
   thumb, not a width set from JS.

   WHAT WAS WRONG WITH THIS PAGE, since most of the file is a fix for it. It
   was one 560px column, five panels tall, every setting carrying two
   paragraphs of prose, every bindable action in one single-file list with a
   two-hundred-word note wedged into one of the labels, and Save at the very
   bottom - three and a half thousand pixels down. Four changes, in order of
   how much they bought:

     1. The action bar is STICKY. Save is always on screen.
     2. The bindings are a TWO-COLUMN grid, which halves the tallest panel.
     3. The long prose is in <details>, shut by default.
     4. Tabs at the top, sticky under the app bar - three of them, each
        showing only its own panels (a rail of anchors until 2026-09-12).

   It also says when there is something to save, which the old page never did.
   See .dirty-mark. */

.settings-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(940px, 100%);
  margin: 0 auto;
  /* Room under the last panel for the sticky bar to sit over. Without this the
     bar covers the bottom of the key grid at the end of the scroll. */
  padding-bottom: 96px;
}

/* The panels live inside #panel, not directly in .settings-page - the whole
   signed-in half of the page is one element so the sign-in gate can replace
   it - so the column gap has to be declared HERE or every panel sits flush
   against the next one. It did, for exactly as long as it took to look. */
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-page > .tbanner { margin-bottom: 0; }   /* the column's gap spaces it */
.page-head { margin-bottom: 2px; }
.page-head .eyebrow { display: block; margin-bottom: 4px; }
.page-head h1 { margin: 0 0 6px; font-size: 24px; }
.page-head p { margin: 0; font-size: 14px; max-width: 68ch; }

.gate-card { padding: 30px; text-align: center; }
.gate-card p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------- the section rail */

/* THE TABS, sticky just under the app bar. Real tabs since 2026-09-12: each one
   shows only its own panels (settings-page.js). They were a rail of anchors over
   a page that listed everything, which read as the page twice.

   The top offset is the app bar's height, so it comes to rest against it
   rather than under it. `z-index` under the bar's 40 so the bar wins where
   they overlap during the scroll. */
.rail {
  position: sticky;
  top: var(--bar-h);
  z-index: 20;
  display: flex;
  gap: 2px;
  margin: 0 0 2px;
  padding: 6px 0;
  overflow-x: auto;
  scrollbar-width: none;
  background: linear-gradient(180deg, var(--bg) 65%, rgba(7, 9, 13, 0));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.rail::-webkit-scrollbar { display: none; }

.rail-i {
  flex: none;
  padding: 9px 16px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
  background: var(--surface);
  border: 1px solid var(--line);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px),
                     calc(100% - 7px) 100%, 0 100%, 0 7px);
  transition: color var(--fast), background var(--fast), border-color var(--fast);
}

.rail-i:hover {
  color: var(--accent);
  background: var(--surface-2);
  border-color: var(--accent-line);
}

/* The selected tab. Filled, lit and bright - it has to read as "this is the
   one you are on", not as one more hover state. */
.rail-i[aria-selected="true"] {
  color: var(--accent-hi);
  background: var(--accent-dim);
  border-color: var(--accent);
}
.rail-i:focus-visible { border-color: var(--accent-hi); outline: none; }

/* ------------------------------------------------------------ setting block */

/* One control inside a panel: a heading, the control, and a note. Panels used
   to be one setting each; the two handling sliders and the two pad sliders are
   pairs and now share a panel, and this is what keeps them apart inside it. */
.set + .set {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.set-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.set-head h3 { font-size: 14.5px; }

.set-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-3);
}

/* A quiet footnote under a control, explaining what it actually does rather
   than repeating its label. */
.note {
  margin: 12px 0 0;
  padding-top: 11px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--fg-3);
}

.note b { color: var(--fg-2); font-weight: 600; }

/* The same note, but it is the FIRST thing in the panel rather than a footnote
   under a control - so it has no rule above it and it sits a step brighter,
   because at the top of a panel it is the introduction rather than the small
   print. */
.note-top {
  margin: -2px 0 18px;
  padding-top: 0;
  border-top: 0;
  font-size: 13px;
  color: var(--fg-2);
}

/* ---------------------------------------------------------- the disclosures */

/* Everything that used to be a second paragraph. Shut it is one line; the
   marker is the platform's own, because a custom one is a background image and
   a rotation for no gain. */
.why {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--fg-3);
}

.why > summary {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-3);
  cursor: pointer;
  padding: 4px 0;
  list-style-position: outside;
}

.why > summary:hover { color: var(--accent); }
.why > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.why > p {
  margin: 4px 0 0;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  line-height: 1.65;
}

/* ------------------------------------------------------------- the switches */

.switches { display: flex; flex-direction: column; gap: 16px; }

/* ------------------------------------------------------------ the bindings */

/* TWO COLUMNS where there is room. Every bindable action gets a row, and in
   one column that is a panel nobody reads to the bottom of; in two it is half
   as deep and the whole of it is on screen at once on a laptop.

   The group headings and the disclosures span the full width, so a heading
   always sits over the rows it names rather than beside them. */
.keys {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 26px;
  align-items: start;
}

.key-group,
.key-why { grid-column: 1 / -1; }

/* A heading inside the bindings list. The text comes from settings.js's action
   list, so this page cannot invent a group the game does not know about. */
.key-group {
  margin: 20px 0 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.key-group:first-child { margin-top: 0; }

.key-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line-soft);
}

.key-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: var(--fg-2);
}

.key-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

/* A chip is the key AND its remove control - there is no second little x to
   aim at on a phone. Notched at a small cut, and monospaced, because it is
   printing a key cap. */
.chip {
  min-width: 32px;
  padding: 5px 8px;
  font: inherit;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
  background: var(--surface-2);
  border: 1px solid var(--line-hard);
  border-radius: 0;
  clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px),
                     calc(100% - 5px) 100%, 0 100%, 0 5px);
  cursor: pointer;
  transition: color var(--fast), background var(--fast), border-color var(--fast);
}

.chip:hover {
  color: var(--bad);
  border-color: var(--bad);
  background: rgba(255, 77, 94, 0.12);
}

.chip-add {
  color: var(--fg-3);
  background: transparent;
  border-style: dashed;
}

.chip-add:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
  border-style: solid;
}

.key-wait {
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  box-shadow: 0 0 10px rgba(53, 214, 240, 0.25);
}

.key-none {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-3);
}

/* The long note that used to live inside a row's label. See paintKeys in
   settings-ui.js for why it moved out here. */
.key-why { margin: 8px 0 4px; }

/* ------------------------------------------------------------ the action bar */

/* STICKY TO THE BOTTOM OF THE VIEWPORT, which is the point of it. `bottom: 0`
   plus a negative bottom margin equal to the page's own bottom padding keeps
   it flush with the last panel once you reach the end of the scroll, instead
   of leaving a strip of ground under it.

   Notched by hand rather than with .card, because a panel's accent tick down
   the left edge reads as a section start and this is a footer. */
.settings-page .actions-row {
  --panel-fill: rgba(16, 22, 32, 0.94);
  --panel-edge: var(--line-hard);
  position: sticky;
  /* Riding on top of the battle log band on a narrow screen, not under it. */
  bottom: calc(10px + var(--bl-bottom, 0px));
  z-index: 22;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding: 12px 14px;
  background-color: var(--panel-fill);
  background-image: var(--notch-lines);
  background-repeat: no-repeat, no-repeat;
  background-position: top left, bottom right;
  background-size: var(--cut) var(--cut), var(--cut) var(--cut);
  background-origin: border-box;
  border: 1px solid var(--panel-edge);
  clip-path: var(--notch);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.actions-spacer { flex: 1 1 auto; }

/* "There is something to save." settings-ui.js reports the working copy going
   dirty; this is what the report looks like. Amber, because it is the colour
   for "attention, not yet a problem" and this is exactly that. */
.dirty-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--warn);
}

.dirty-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--warn);
  box-shadow: 0 0 8px rgba(255, 171, 46, 0.7);
}

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

/* One column for the bindings, and the rail's chips tighten up. 720px is
   where a key row's label and three chips stop fitting in half the page. */
@media (max-width: 720px) {
  .keys { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .settings-page .card { padding: 16px; }
  .key-row { flex-wrap: wrap; gap: 6px; min-height: 0; padding: 9px 0; }
  .key-chips { justify-content: flex-start; width: 100%; }
  .rail-i { padding: 7px 11px; }

  /* Reset first and Save last, both stretched: on a phone the bar is two rows
     and the useful half must be the one under the thumb. The unsaved mark
     takes the whole first row. */
  .dirty-mark { width: 100%; }
  .actions-spacer { display: none; }
  .settings-page .actions-row .btn { flex: 1 1 auto; }
}
