/* ACK/NAK Relay console shell — layout only. Every colour is a role from tokens.css;
   no literal colour belongs in this file (shell_test.go checks). Sizes follow
   design/v2/tokens.json: header 56 px, touch floor 44 px, controls 52 px, buttons 56 px,
   no text under 11 px. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--accent-text); }

/* The label style: Plex Mono 700, 12 px, uppercase, 0.1 em. "RELAY" after the mark and the
   placeholder line use it. */
.label {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ── header ─────────────────────────────────────────────────────────────── */

/* The header wraps intrinsically at every width: the nav declares its real minimum width
   (four 44 px targets plus gaps) and drops to a second row, with the actions beside it,
   whenever the row does not fit. No fixed cutoff, so narrow landscape and tablet widths
   just above a phone breakpoint cannot overflow either. */
.shell-header {
  min-height: 56px;
  height: auto;
  padding: 0 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-sub);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  text-decoration: none;
  color: var(--text-primary);
}
.brand img { height: 19px; width: auto; display: block; }
/* One mark file per theme; the tokens decide which is visible. */
.mark-ondark { display: none; }
:root.theme-dark .mark-onlight { display: none; }
:root.theme-dark .mark-ondark { display: block; }

.shell-nav {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin-left: 8px;
  min-height: 56px;
  flex: 1 1 auto;
  min-width: 188px; /* four 44 px targets + three 4 px gaps */
}
.shell-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  text-decoration: none;
  color: var(--text-sec);
  font-weight: 700;
  font-size: 14px;
  border-bottom: 3px solid transparent;
}
.shell-nav a:hover { color: var(--text-primary); }
.shell-nav a[aria-current="page"] {
  color: var(--accent-text);
  border-bottom-color: var(--accent-border);
}

.shell-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── controls ───────────────────────────────────────────────────────────── */

.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--press-ms), filter var(--press-ms);
}
.btn:hover { background: var(--bg-subtle); }
.btn:active { transform: scale(0.97); filter: brightness(0.88); }
.btn:focus-visible { outline: 3px solid var(--accent-border); outline-offset: 2px; }
/* A toggle that is on (the theme switch): the state shows in the styling, the name stays. */
.btn[aria-pressed="true"] {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
  color: var(--accent-text);
}

.btn-primary {
  min-height: 56px;
  border-color: var(--accent-border);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.btn-primary:hover { background: var(--accent); filter: brightness(0.94); }

/* ── page body ──────────────────────────────────────────────────────────── */

.shell-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.screen-title {
  margin: 0 0 16px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
/* Section headings carry a > prompt (design v2 principle 5). */
.screen-title::before { content: "> "; color: var(--accent-text); }

.placeholder {
  padding: 32px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-sub);
  border-radius: 14px;
  color: var(--text-muted);
}
.placeholder .cursor {
  display: inline-block;
  width: 0.55em;
  height: 0.9em;
  vertical-align: text-bottom;
  margin-left: 0.25em;
  background: var(--cursor);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .placeholder .cursor { animation: none; }
  .btn { transition: none; }
}

.tool-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.tool-list a {
  display: block;
  min-height: 64px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-sub);
  border-radius: 14px;
  color: var(--text-primary);
  text-decoration: none;
}
.tool-list a:hover { border-color: var(--border); }
.tool-list a:focus-visible { outline: 3px solid var(--accent-border); outline-offset: 2px; }
.tool-list .name { display: block; font-weight: 700; font-size: 20px; line-height: 1.2; }
.tool-list .helper { display: block; font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* ── login ──────────────────────────────────────────────────────────────── */

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login {
  width: 100%;
  max-width: 360px;
  padding: 32px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-sub);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login .brand { align-self: flex-start; }
.login .brand img { height: 24px; }
.login label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-sec);
}
.login input {
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 16px;
}
.login input:focus { outline: 3px solid var(--accent-border); outline-offset: 1px; }
.login .err {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--state-refused-bg);
  color: var(--error);
  font-size: 14px;
  font-weight: 700;
}
.login .theme-row { display: flex; justify-content: flex-end; }

/* Phone widths (320-430 px): the header wraps in DOM order, so focus order equals visual
   order. The mark (row 1), the nav as a full-width grid of four equal 44 px targets
   (row 2), then the actions right-aligned (row 3). No visual reordering, nothing hidden
   behind a menu, nothing scrolls sideways. */
@media (max-width: 600px) {
  .shell-header { gap: 0 8px; padding: 0 8px; }
  .shell-nav {
    flex-basis: 100%;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border-top: 1px solid var(--border-sub);
  }
  .shell-nav a { justify-content: center; padding: 0 4px; font-size: 12px; }
  .shell-actions { min-height: 52px; }
  .btn { padding: 0 10px; }
}
