/* ХРОМ//ТАКТ. Colours, type and shapes are tokens on :root; the dark
   scheme is the main one, the light one a muted variant. Fonts are
   self-hosted (fonts/, SIL OFL 1.1), no requests to font services.
   Cyan marks only what is selected or active; yellow only money, new
   levels and important events; lime only the offline (breach) screen. */

@font-face { font-family: "Oswald"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/oswald-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Oswald"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/oswald-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2122, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "Oswald"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/oswald-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Oswald"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/oswald-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2122, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "Play"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/play-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Play"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/play-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2122, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "Play"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/play-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Play"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/play-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2122, U+2212, U+FEFF, U+FFFD; }

:root {
  color-scheme: light dark;

  /* Light: warm grey, dark red text, darkened cyan, no glow. */
  --bg: #ece7e2;
  --surface: #f7f3ef;
  --surface-2: #e2d8d2;
  --fg: #7a0f14;
  --muted: #8a3a36;
  --line: #c9a9a5;
  --line-strong: #a8716d;
  --active: #00646e;
  --active-fg: #ffffff;
  --active-text: #00606a;
  --money: #6b5c00;
  --hp: #c0001f;
  --enemy: #a8330f;
  --hazard: #e0c200;
  --hazard-ink: #1a1a1a;
  --glow: transparent;
  --disabled-fg: #8d6c69;
  --disabled-line: #b39a97;
  --scan: rgba(80, 20, 20, 0.03);
  --vignette: rgba(60, 20, 20, 0.08);
  /* Breach (offline) screen. */
  --breach-bg: #eef1de;
  --breach-fg: #445200;
  --breach-muted: #5b6b10;
  --breach-line: #8a9a3a;

  --cut: 10px;
  --radius: 0px;
  --gap: 12px;
  --pad: 16px;
  --tap: 44px;
  --font: "Play", system-ui, sans-serif;
  --head: "Oswald", "Play", system-ui, sans-serif;
}

/* Dark (main): near-black with a red cast, salmon text. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0709;
    --surface: #170b0e;
    --surface-2: #221014;
    --fg: #ff5f58;
    --muted: #d05a55;
    --line: #5c2024;
    --line-strong: #a8403f;
    --active: #5ef6ff;
    --active-fg: #0e0709;
    --active-text: #5ef6ff;
    --money: #fcee0a;
    --hp: #ff1f3d;
    --enemy: #ff8a3d;
    --hazard: #fcee0a;
    --hazard-ink: #0e0709;
    --glow: rgba(255, 95, 88, 0.55);
    --disabled-fg: #9a5f5c;
    --disabled-line: #6b3a3b;
    --scan: rgba(0, 0, 0, 0.22);
    --vignette: rgba(0, 0, 0, 0.55);
    --breach-bg: #0a0c05;
    --breach-fg: #cdf04a;
    --breach-muted: #8fa632;
    --breach-line: #4d5c1c;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

/* Scanlines and a vignette on the page background only: panels, the
   header and tabs have their own fill, so text contrast is untouched. */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  background: radial-gradient(ellipse at center, transparent 55%, var(--vignette));
}

body::after {
  background: repeating-linear-gradient(to bottom, transparent 0 2px, var(--scan) 2px 3px);
}

h1,
h2,
h3,
p,
ul,
ol {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

/* Menus, headings and buttons: condensed, upper case. */
h1,
h2,
.tab,
button,
.dialog h2 {
  font-family: var(--head);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Buttons: 1 px frame and one chamfered corner. The frame is drawn by
   ::before (the outline shape) and ::after (the fill, 1 px inside). */
button {
  position: relative;
  isolation: isolate;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-size: 0.95rem;
  cursor: pointer;
}

button::before,
button::after {
  content: "";
  position: absolute;
  z-index: -1;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%);
}

button::before {
  inset: 0;
  background: var(--line-strong);
}

button::after {
  inset: 1px;
  background: var(--surface-2);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--cut) + 0.5px), calc(100% - var(--cut) + 0.5px) 100%, 0 100%);
}

button.primary::before {
  background: var(--fg);
}

/* Selected or running: solid cyan, dark text. */
button[aria-pressed="true"],
.tab[aria-selected="true"] {
  color: var(--active-fg);
}

button[aria-pressed="true"]::before,
button[aria-pressed="true"]::after,
.tab[aria-selected="true"]::before,
.tab[aria-selected="true"]::after {
  background: var(--active);
}

/* Unavailable: muted, a dashed frame without the chamfer, no fill. The
   reason is written in the card (.reason), not in the button. */
button:disabled {
  color: var(--disabled-fg);
  border: 1px dashed var(--disabled-line);
  cursor: not-allowed;
}

button:disabled::before,
button:disabled::after {
  display: none;
}

.reason {
  margin-top: 2px;
  padding-left: 8px;
  border-left: 2px dashed var(--disabled-line);
  color: var(--muted);
  font-size: 0.875rem;
}

:focus-visible {
  outline: 2px solid var(--active-text);
  outline-offset: 3px;
}

/* A short chromatic shift on hover of active controls. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  button.primary:not(:disabled):hover,
  button[aria-pressed="true"]:hover,
  .tab[aria-selected="true"]:hover {
    animation: glitch 0.32s steps(2) 1;
  }
}

@keyframes glitch {
  0% { text-shadow: -2px 0 var(--active), 2px 0 var(--hp); transform: translateX(1px); }
  50% { text-shadow: 2px 0 var(--active), -2px 0 var(--hp); transform: translateX(-1px); }
  100% { text-shadow: none; transform: none; }
}

textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.3 ui-monospace, monospace;
  word-break: break-all;
}

/* Decorative service text: never in the layout flow, never read aloud. */
.micro {
  position: absolute;
  font: 9px/1 var(--font);
  letter-spacing: 0.25em;
  color: var(--muted);
  opacity: 0.75;
  pointer-events: none;
  white-space: nowrap;
}

/* Layout: one column on phones; tabs down the side on wide screens. */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "hud" "tabs" "panel";
  max-width: 1280px;
  margin: 0 auto;
}

.hud {
  grid-area: hud;
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  gap: 6px;
  padding: 10px var(--pad) 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--fg);
  box-shadow: 0 1px 10px var(--glow);
}

.hud-top {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
}

.hud-top .micro {
  left: 50%;
  top: 4px;
}

.hud h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--fg);
  text-shadow: 0 0 8px var(--glow);
}

.cash {
  font-weight: 700;
  color: var(--money);
}

.hud-activity {
  display: flex;
  align-items: center;
  gap: var(--gap);
}

.hud-bars {
  flex: 1;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.activity,
.hp-text {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity {
  color: var(--active-text);
}

.hp-text {
  color: var(--muted);
}

/* Errors and the flatline: the yellow and black warning stripe. */
.notice:empty {
  display: none;
}

.notice,
.feed .alarm,
.summary .alarm {
  padding: 6px 10px 6px 18px;
  color: var(--fg);
  background:
    repeating-linear-gradient(-45deg, var(--hazard) 0 6px, var(--hazard-ink) 6px 12px) left / 8px 100% no-repeat,
    var(--surface-2);
}

.tabs {
  grid-area: tabs;
  display: flex;
  gap: 6px;
  padding: 10px var(--pad);
  overflow-x: auto;
  scrollbar-width: thin;
  background: var(--bg);
}

/* More tabs behind an edge: that edge fades out. */
.tabs.more-right {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
}

.tabs.more-left {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent);
}

.tabs.more-left.more-right {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
}

.tab {
  flex: none;
  color: var(--muted);
}

.tab::before {
  background: var(--line);
}

.tab::after {
  background: var(--bg);
}

.panel {
  grid-area: panel;
  display: grid;
  gap: var(--gap);
  align-content: start;
  padding: 0 var(--pad) var(--pad);
  min-width: 0;
}

@media (min-width: 900px) {
  .app {
    grid-template-columns: 200px minmax(0, 1fr);
    grid-template-areas: "hud hud" "tabs panel";
  }

  .tabs {
    flex-direction: column;
    align-self: start;
    position: sticky;
    top: 140px;
    overflow: visible;
  }

  .tab {
    text-align: left;
  }

  .panel {
    padding-top: 10px;
  }
}

@media (max-width: 480px) {
  .hud-top .micro {
    display: none;
  }
}

/* Bars. The fill is scaled with a transform, so a frame's update never
   triggers layout. Action progress and XP are segmented; HP is thin and
   solid. */

.bar {
  height: 10px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--fg);
  transform-origin: left center;
  will-change: transform;
}

.bar.progress .bar-fill,
.bar.thin .bar-fill,
.bar.breach-bar .bar-fill {
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 3px, transparent 3px 5px);
  mask: repeating-linear-gradient(90deg, #000 0 3px, transparent 3px 5px);
}

.bar.progress .bar-fill {
  background: var(--active);
  box-shadow: 0 0 8px var(--active);
}

.bar.thin {
  height: 6px;
}

.bar.hp,
.bar.enemy {
  height: 3px;
}

.bar.hp .bar-fill {
  background: var(--hp);
}

.bar.enemy .bar-fill {
  background: var(--enemy);
}

/* Cards: 1 px frame, one chamfered corner, the red left edge and corner
   ticks. The frame is ::before, the fill with the edge and ticks ::after. */

.cards {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  align-items: start;
}

.card {
  position: relative;
  isolation: isolate;
  display: grid;
  gap: 8px;
  padding: 12px 14px 18px 16px;
}

.card::before,
.card::after {
  content: "";
  position: absolute;
  z-index: -1;
}

.card::before {
  inset: 0;
  background: var(--line);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%);
}

.card::after {
  inset: 1px;
  clip-path: polygon(0 0, calc(100% - 15.5px) 0, 100% 15.5px, 100% 100%, 0 100%);
  background:
    linear-gradient(var(--fg), var(--fg)) left top / 2px 100% no-repeat,
    linear-gradient(var(--fg), var(--fg)) right 4px bottom 4px / 10px 1px no-repeat,
    linear-gradient(var(--fg), var(--fg)) right 4px bottom 4px / 1px 10px no-repeat,
    linear-gradient(var(--fg), var(--fg)) left 6px bottom 4px / 10px 1px no-repeat,
    var(--surface);
}

.card > .micro {
  right: 20px;
  bottom: 5px;
}

.card:has(> .feed:empty) {
  display: none;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card h2 {
  font-size: 1.05rem;
  color: var(--fg);
}

.tag {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 400;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.rows {
  display: grid;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.rows > .row:first-child {
  border-top: 0;
}

.row h3 {
  font-size: 0.975rem;
  font-weight: 700;
}

.row.active h3 {
  color: var(--active-text);
}

.row-text {
  flex: 1 1 200px;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.row-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty {
  padding: var(--pad);
  color: var(--muted);
  text-align: center;
}

.feed li {
  padding: 6px 0;
  border-top: 1px solid var(--line);
}

.feed li:first-child {
  border-top: 0;
}

.feed .highlight,
.summary .highlight {
  color: var(--money);
}

.warnings {
  display: grid;
  gap: 4px;
  padding: 10px 12px 10px 20px;
  background:
    repeating-linear-gradient(-45deg, var(--hazard) 0 6px, var(--hazard-ink) 6px 12px) left / 8px 100% no-repeat,
    var(--surface-2);
}

.field {
  display: grid;
  gap: 4px;
}

/* Dialogs over the page. */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: var(--pad);
  background: rgb(0 0 0 / 0.6);
}

.dialog {
  position: relative;
  display: grid;
  gap: var(--gap);
  width: min(100%, 460px);
  max-height: 100%;
  overflow: auto;
  padding: 22px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--fg);
}

.dialog h2 {
  font-size: 1.15rem;
}

.summary {
  display: grid;
  gap: 4px;
}

/* The breach screen: offline progress in its own lime palette. */

.breach .dialog {
  --fg: var(--breach-fg);
  --muted: var(--breach-muted);
  --line: var(--breach-line);
  --line-strong: var(--breach-line);
  --surface-2: color-mix(in srgb, var(--breach-fg) 12%, var(--breach-bg));
  color: var(--breach-fg);
  background:
    linear-gradient(var(--breach-fg), var(--breach-fg)) left top / 14px 1px no-repeat,
    linear-gradient(var(--breach-fg), var(--breach-fg)) left top / 1px 14px no-repeat,
    linear-gradient(var(--breach-fg), var(--breach-fg)) right bottom / 14px 1px no-repeat,
    linear-gradient(var(--breach-fg), var(--breach-fg)) right bottom / 1px 14px no-repeat,
    var(--breach-bg);
  border: 1px solid var(--breach-line);
}

.breach .dialog > .micro {
  right: 16px;
  top: 8px;
}

.breach-timer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--breach-fg);
  font-family: var(--head);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.breach-timer strong {
  font-family: var(--font);
  font-size: 1.6rem;
  letter-spacing: 0.04em;
}

.bar.breach-bar {
  height: 12px;
}

.bar.breach-bar .bar-fill {
  background: var(--breach-fg);
}

.breach-pct {
  text-align: right;
  color: var(--breach-muted);
}

.hex {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px 6px;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--breach-muted);
  opacity: 0.8;
}

.hex .hot {
  color: var(--breach-fg);
}

.breach .summary .highlight {
  color: var(--breach-fg);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill {
    will-change: auto;
  }
}
