/* base.css — EPOCH app shell: reset, shared typography, header/fkeys/cmdbar, tape,
   footer, phone tabbar, dialog, toast, study picker, flash animations.
   Colors/spacing come from tokens.css only. Sharp corners, hairline rules, no shadows. */

/* ---------------------------------------------------------------- reset */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background: #000;
  color: var(--text);
  overflow-x: hidden;
}

html {
  scrollbar-color: var(--rule) #000;
  scrollbar-width: thin;
}

body {
  font: 400 12px/16px var(--mono);
  font-variant-numeric: tabular-nums slashed-zero;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: var(--top-h) var(--tape-h) auto 1fr var(--foot-h);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
}

button {
  cursor: pointer;
}

canvas,
svg {
  display: block;
}

a {
  color: var(--orange);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::selection {
  background: var(--orange);
  color: #000;
}

:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 1px;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--rule);
}

::-webkit-scrollbar-track {
  background: #000;
}

/* skip link: off-canvas until focused */
.skip {
  position: fixed;
  top: 0;
  left: -9999px;
  z-index: 100;
  padding: 4px 8px;
  background: var(--orange);
  color: #000;
  font-weight: 700;
}

.skip:focus {
  left: 0;
}

/* visually hidden but screen-reader available */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.noscript {
  display: block;
  padding: 12px;
  color: var(--amber);
  font-size: 12px;
}

/* ------------------------------------------------- shared text utilities */

.num {
  font-variant-numeric: tabular-nums slashed-zero;
}

.dim   { color: var(--dim); }
.strong { font-weight: 700; }
.warn  { color: var(--amber); }
.up    { color: var(--up); }
.dn    { color: var(--down); }
.flat  { color: var(--dim); }

.big  { font-size: var(--fs-xl); }
.huge { font-size: var(--fs-xxl); }

.note {
  font-size: var(--fs-s);
  color: var(--dim);
}

.label {
  font-size: var(--fs-xs);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* badge base chrome (kinds are colored in panels.css) */
.bdg,
#live-badge {
  margin: 0 8px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 14px;
}

/* ---------------------------------------------------------------- header */

#top {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--rule);
}

#brand {
  flex: none;
  height: 100%;
  display: flex;
  align-items: baseline;
  padding: 0 12px;
  border-right: 1px solid var(--rule);
}

#brand-name,
#brand-tag {
  line-height: var(--top-h);
}

#brand-name {
  font-size: var(--fs-l);
  font-weight: 700;
  color: var(--orange);
  letter-spacing: .14em;
}

#brand-tag {
  margin-left: 8px;
  font-size: var(--fs-xs);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* function-key screen nav */
#fkeys {
  flex: none;
  display: flex;
  height: 100%;
}

.fk {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 10px;
  border-right: 1px solid var(--rule);
  color: var(--amber);
  font-family: var(--mono);
  font-size: var(--fs-s);
  font-weight: 700;
  letter-spacing: .06em;
}

.fk:hover {
  background: var(--orange-bg);
}

.fk-k,
.cmd-k {
  background: var(--amber);
  color: #000;
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  padding: 0 3px;
}

.fk-k {
  margin-right: 6px;
}

.fk[aria-current="page"] {
  background: var(--orange);
  color: #000;
}

.fk[aria-current="page"] .fk-k {
  background: #000;
  color: var(--orange);
}

/* command bar */
#cmd {
  position: relative;
  flex: 1 1 auto;
  min-width: 180px;
  max-width: 420px;
  margin: 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cmd-k {
  flex: none;
}

#cmd-input {
  width: 100%;
  flex: 1 1 auto;
  min-width: 0;
  height: 22px;
  padding: 0 8px;
  background: #000;
  border: 1px solid var(--rule);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--fs-m);
  caret-color: var(--orange);
}

#cmd-input::placeholder {
  color: var(--faint);
}

#cmd-input:focus {
  outline: none;
  border-color: var(--orange);
}

#cmd-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  background: #000;
  border: 1px solid var(--orange);
  z-index: 50;
  max-height: 60vh;
  overflow: auto;
  list-style: none;
}

.cmd-o {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  cursor: pointer;
}

.cmd-kind {
  font-size: var(--fs-xs);
  color: var(--dim);
}

.cmd-l {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmd-o.is-active,
.cmd-o:hover {
  background: var(--orange);
  color: #000;
}

.cmd-o.is-active .cmd-kind,
.cmd-o:hover .cmd-kind {
  color: inherit;
}

.cmd-o.is-active .dim,
.cmd-o:hover .dim {
  color: #000;
  opacity: .7;
}

/* live badge + data health button + utc clock */
#live-badge {
  flex: none;
}

#health-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 10px;
  border-left: 1px solid var(--rule);
  color: var(--text);
  font-size: var(--fs-s);
  font-weight: 700;
  letter-spacing: .06em;
}

#health-btn:hover {
  background: var(--orange-bg);
}

#health-btn .dot {
  width: 8px;
  height: 8px;
  background: var(--dim);
}

#health-btn.h-ok .dot    { background: var(--up); }
#health-btn.h-part .dot  { background: var(--amber); }
#health-btn.h-stale .dot { background: var(--down); }
#health-btn.h-off .dot {
  background: var(--down);
  animation: blink 1s steps(2) infinite;
}

#utc {
  flex: none;
  padding: 0 12px;
  border-left: 1px solid var(--rule);
  color: var(--dim);
  font-size: var(--fs-s);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ tape */

#tape {
  height: var(--tape-h);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  white-space: nowrap;
}

#tape::-webkit-scrollbar {
  display: none;
}

.tape-in {
  display: flex;
  height: 100%;
}

.tp {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px 0;
  border-right: 1px solid var(--rule-2);
}

.tp-k {
  font-size: var(--fs-xs);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.tp-v {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 5ch;
  text-align: right;
}

.tp-m {
  font-size: var(--fs-xs);
}

/* ------------------------------------------------------------------ main */

main#main {
  overflow: auto;
  min-height: 0;
}

#page.grid {
  display: grid;
  gap: var(--gap);
  background: var(--rule); /* 1px gaps read as hairline rules between panels */
  min-height: 100%;
}

/* ---------------------------------------------------------------- footer */

#foot {
  height: var(--foot-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  border-top: 1px solid var(--rule);
  font-size: var(--fs-xs);
  color: var(--dim);
}

.disclaimer {
  color: var(--amber);
}

#home-link {
  color: var(--orange);
  text-decoration: none;
}

#home-link:hover {
  text-decoration: underline;
}

.tv-attr-foot {
  color: var(--dim);
  text-decoration: none;
}

.tv-attr-foot:hover {
  text-decoration: underline;
}

#foot-asof {
  margin-left: auto;
}

/* -------------------------------------------------------- phone tab bar */

#tabbar {
  display: none;
}

/* ------------------------------------------------ health dialog + toast */

#health-dlg {
  position: fixed;
  inset: 48px 10% auto 10%;
  max-height: calc(100vh - 96px);
  overflow: auto;
  background: #000;
  border: 1px solid var(--orange);
  z-index: 60;
}

.dlg-h {
  height: 20px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: var(--orange);
  color: #000;
  font-size: var(--fs-s);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.dlg-x {
  margin-left: auto;
  height: 100%;
  padding: 0 8px;
  background: #000;
  color: var(--orange);
  border: 0;
  font-family: var(--mono);
  font-size: var(--fs-s);
  font-weight: 700;
}

.dlg-b {
  padding: 8px;
}

#toast {
  position: fixed;
  bottom: 32px;
  right: 12px;
  padding: 4px 8px;
  background: #000;
  border: 1px solid var(--orange);
  font-size: var(--fs-s);
  color: var(--text);
  z-index: 80;
}

#toast:empty {
  display: none;
}

/* ------------------------------------------------------- study picker */

.picker {
  position: fixed;
  width: 520px;
  max-height: 70vh;
  overflow: auto;
  background: #000;
  border: 1px solid var(--orange);
  z-index: 70;
}

.picker-h {
  position: sticky;
  top: 0;
  background: #000;
  border-bottom: 1px solid var(--rule);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.picker-q {
  flex: 1 1 auto;
  min-width: 0;
  height: 22px;
  padding: 0 8px;
  background: #000;
  border: 1px solid var(--rule);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--fs-m);
  caret-color: var(--orange);
}

.picker-q::placeholder {
  color: var(--faint);
}

.picker-q:focus {
  outline: none;
  border-color: var(--orange);
}

.picker .label {
  padding: 8px 8px 4px;
}

.pk-r {
  display: grid;
  grid-template-columns: 16px 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 2px 8px;
  min-height: 24px;
  cursor: pointer;
}

.pk-r:hover {
  background: var(--orange-bg);
}

.pk-r input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--orange);
}

.pk-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pk-tag {
  font-size: 9px;
  color: var(--dim);
  border: 1px solid var(--rule);
  padding: 0 3px;
  line-height: 14px;
}

.pk-n {
  width: 52px;
  height: 18px;
  padding: 0 4px;
  background: #000;
  border: 1px solid var(--rule);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--fs-s);
  appearance: textfield;
}

.pk-n::-webkit-outer-spin-button,
.pk-n::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* phone: bottom sheet variant (position set here, JS only places wide popovers) */
.picker-sheet {
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: auto;
  max-height: 75vh;
  border-width: 1px 0 0;
}

/* ------------------------------------------------------------ animations */

@keyframes flUp {
  from { background-color: rgba(46, 230, 166, .35); }
  to   { background-color: transparent; }
}

@keyframes flDn {
  from { background-color: rgba(255, 77, 77, .35); }
  to   { background-color: transparent; }
}

@keyframes blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.fl-up { animation: flUp .7s ease-out; }
.fl-dn { animation: flDn .7s ease-out; }

/* --------------------------------------------------------- breakpoints */

@media (max-width: 1099px) {
  #brand-tag { display: none; }
}

/* phone */
@media (max-width: 760px) {
  body {
    grid-template-rows: auto var(--tape-h) auto 1fr auto;
    padding-bottom: var(--tabbar-h);
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  }

  #top {
    height: auto;
    flex-wrap: wrap;
  }

  #brand {
    height: 32px;
  }

  #fkeys { display: none; }

  #cmd {
    order: 9;
    flex: 1 0 100%;
    max-width: none;
    margin: 0 0 6px 0;
    padding: 0 8px;
  }

  #utc { display: none; }

  main#main { overflow: visible; }

  #foot {
    flex-wrap: wrap;
    height: auto;
    padding: 6px 12px;
    line-height: 16px;
  }

  #tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--tabbar-h);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: #000;
    border-top: 1px solid var(--orange);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    z-index: 40;
  }

  .tb {
    flex: 0 0 20%;
    min-width: 72px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-right: 1px solid var(--rule-2);
    color: var(--amber);
    font-family: var(--mono);
    font-size: var(--fs-xs);
    font-weight: 700;
  }

  .tb-k {
    font-size: 9px;
  }

  .tb-l {
    letter-spacing: .06em;
  }

  .tb[aria-current="page"] {
    background: var(--orange);
    color: #000;
  }

  #health-dlg {
    inset: 0;
    max-height: none;
  }
}

/* large screens */
@media (min-width: 1920px) {
  #brand-tag { display: inline; }
}

@media (min-width: 2560px) {
  body {
    font: 400 13px/18px var(--mono);
  }

  :root {
    --top-h: 36px;
  }

  #top {
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
