/* Хай-тек и брутализм: алюминиевый корпус, чёрный экран, жёсткие рёбра, один сигнальный цвет.
   Плотность дизеринга означает тяжесть проблемы. */
@font-face { font-family: "Medeo Sans"; src: url("../src/assets/fonts/MedeoSansVariable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Medeo Digits"; src: url("../src/assets/fonts/MedeoMonoVariable.woff2") format("woff2"); unicode-range: U+0030-0039; font-weight: 100 900; font-display: swap; }

:root {
  --alu: #c6cbc9;
  --plate: #e7eae8;
  --ink: #000000;
  --mute: #3f4745;
  --red: #ff3d2e;
  --white: #f4f6f5;
  --rule: 2px solid var(--ink);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--alu); }
body { font: 500 15px/1.4 "Medeo Digits", "Medeo Sans", system-ui, sans-serif; color: var(--ink); min-height: 100vh; }
button { font: inherit; color: inherit; cursor: pointer; border-radius: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
ol, ul { list-style: none; }
h1, h2 { font-size: 15px; font-weight: 700; }

.brand { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 8px 8px; }
.brand strong { font-size: 28px; font-weight: 900; letter-spacing: -.02em; }
.brand span { font-size: 13px; opacity: .7; }

main { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr); grid-template-areas: "screen money" "screen factors" "next next"; grid-template-rows: auto 1fr auto; gap: 2px; background: var(--ink); border-bottom: var(--rule); max-width: 1440px; margin: 0 auto; border-inline: var(--rule); }
main > section { background: var(--plate); min-width: 0; }

.money { grid-area: money; padding: 20px; }
.free { font-size: clamp(52px, 7.4vw, 104px); font-weight: 900; line-height: .95; letter-spacing: -.045em; white-space: nowrap; margin: 6px 0 14px; }
.alert { display: inline-block; padding: 5px 10px; background: var(--red); font-weight: 700; }
.alert.calm { background: var(--ink); color: var(--white); }
dl { display: grid; grid-template-columns: 1fr 1fr; margin: 18px 0; border-block: var(--rule); }
dl div { padding: 10px 0; }
dl div + div { padding-left: 14px; border-left: var(--rule); }
dt { color: var(--mute); font-size: 13px; }
dd { font-size: 22px; font-weight: 800; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn { position: relative; min-height: 48px; padding: 0 18px; border: var(--rule); isolation: isolate; overflow: hidden; white-space: nowrap; background-color: var(--plate); box-shadow: 4px 4px 0 var(--ink); font-weight: 700; text-align: left; transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
/* дизер лежит над фоном кнопки и под её текстом */
.btn > canvas { position: absolute; z-index: -1; right: 0; bottom: 0; image-rendering: pixelated; pointer-events: none; }
.btn-main { flex: 1; min-width: 280px; padding-right: 96px; background-color: var(--ink); color: var(--white); box-shadow: 4px 4px 0 var(--red); }
.btn-main:active { box-shadow: 0 0 0 var(--red); }

/* экран остаётся перед глазами, пока листаешь причины */
.screen { grid-area: screen; background: var(--ink) !important; color: var(--white); display: flex; flex-direction: column; padding: 12px; position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; min-height: 520px; max-height: 920px; }
.stage { position: relative; flex: 1; width: 100%; min-height: 0; touch-action: pan-y; }
#logo { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.tag { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; color: var(--white); white-space: nowrap; font-size: 13px; }
.tag i { display: grid; place-items: center; width: 32px; height: 32px; border: 2px solid var(--white); background: var(--ink); font-style: normal; font-weight: 800; }
.tag.problem i { border-color: var(--red); background: var(--red); color: var(--ink); }
.tag[aria-pressed="true"] i { outline: 2px solid var(--white); outline-offset: 3px; }
.tag[data-side="left"] { flex-direction: row-reverse; text-align: right; }
.tag[data-side="left"] span, .tag[data-side="right"] span { max-width: 100px; white-space: normal; line-height: 1.2; }
.tag[data-side="right"] { text-align: left; }
.tag[data-side="top"] { flex-direction: column-reverse; gap: 4px; }
.tag[data-side="bottom"] { flex-direction: column; gap: 4px; }
.readout { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 24px; padding: 8px 8px 4px; }
.readout span { display: block; font-size: 13px; opacity: .7; }
.readout output { display: block; font-size: 44px; font-weight: 900; line-height: 1; min-width: 3.2em; }
#verdict { flex: 1; min-width: 180px; padding-bottom: 4px; }
.btn-screen { background-color: var(--ink); border-color: var(--white); color: var(--white); box-shadow: 4px 4px 0 var(--white); }
.btn-screen:active { box-shadow: 0 0 0 var(--white); }

.factors { grid-area: factors; }
.factors h2 { padding: 14px 20px 12px; border-bottom: var(--rule); }
.factor { border-bottom: 1px solid var(--ink); }
.factor:last-child { border-bottom: 0; }
.row { transition: background-color .15s ease, color .15s ease; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto 14px; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 0 0 20px; border: 0; background: none; text-align: left; }
.row b { font-weight: 700; }
.row em { font-style: normal; text-align: right; }
.row u { align-self: stretch; image-rendering: pixelated; border-left: 1px solid var(--ink); }
.row[aria-expanded="true"] { background: var(--ink); color: var(--white); }
/* раскрытие: ряд сетки растёт от 0 до высоты содержимого; свёрнутое помечено inert */
.more { display: grid; grid-template-rows: 1fr; background: var(--ink); color: var(--white); transition: grid-template-rows .28s cubic-bezier(.32, .72, 0, 1); }
.more[inert] { grid-template-rows: 0fr; }
.more > div { min-height: 0; overflow: hidden; }
.more > div > div { padding: 12px 20px 18px 60px; transition: opacity .28s ease; }
.more[inert] > div > div { opacity: 0; }
.more p { max-width: 62ch; margin-bottom: 14px; }
.btn-fix { background-color: var(--red); border-color: var(--red); color: var(--ink); box-shadow: 4px 4px 0 var(--white); padding-right: 96px; }
.btn-fix:active { box-shadow: 0 0 0 var(--white); }

.next { grid-area: next; }
.next h2 { padding: 14px 20px 12px; border-bottom: var(--rule); }
.next ul { display: grid; grid-template-columns: repeat(3, 1fr); }
.next li { display: grid; padding: 12px 20px 18px; }
.next li + li { border-left: var(--rule); }
.next span { color: var(--mute); font-size: 13px; }
.next b { font-weight: 700; }
.next em { font-style: normal; font-size: 26px; font-weight: 800; margin-top: 6px; }

@media (hover: hover) and (pointer: fine) {
  .btn:hover { transform: translate(-1px, -1px); }
  .row:hover:not([aria-expanded="true"]) { background: var(--alu); }
}

@media (max-width: 900px) {
  main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "screen" "money" "factors" "next"; grid-template-rows: none; border-inline: 0; }
  .money { padding: 16px; }
  .free { font-size: clamp(48px, 16vw, 96px); }
  .stage { flex: none; height: min(88vw, 460px); min-height: 0; }
  .screen { position: static; height: auto; min-height: 0; max-height: none; padding: calc(8px + env(safe-area-inset-top)) 8px 12px; }
  .tag span { display: none; }
  .next ul { grid-template-columns: 1fr; }
  .next li + li { border-left: 0; border-top: var(--rule); }
  .factors h2, .next h2 { padding-inline: 16px; }
  .row { padding-left: 16px; gap: 10px; }
  .more > div > div { padding: 12px 16px 18px; }
  /* главное действие всегда под пальцем */
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .btn-main { position: fixed; z-index: 2; left: 12px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom)); border-color: var(--white); }
  .btn-main:active { transform: translate(4px, 4px); }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .row, .more, .more > div > div { transition: none; }
}
