/* CodeRooms — the project site.
 *
 * One stylesheet, no build step: the palette is the application's, so the two
 * read as one product, and the file can be served by Caddy or dropped on any
 * static host without a toolchain in between.
 *
 * Mobile first. Everything that is a grid collapses to one column, the hero
 * mock shrinks rather than scrolls, and every animation is off for anybody who
 * asked their system for less motion. */

:root,
:root[data-theme='dark'] {
  --bg: #0d0f14;
  --bg-raised: #12141a;
  --bg-panel: #171a22;
  --border: #262a35;
  --border-hover: #39404f;
  --text: #d7dae0;
  --text-muted: #8a91a0;
  --text-faint: #5c6373;
  --accent: #4f8ef7;
  --accent-soft: #1b2a3f;
  --on-accent: #fff;
  --ok: #3fa66a;
  --warn: #d99a2b;
  --rule: rgba(125, 155, 215, 0.13);
  --who-a: #e0567a;
  --who-b: #4f8ef7;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f4f6f8;
  --bg-raised: #ffffff;
  --bg-panel: #ffffff;
  --border: #d5dae1;
  --border-hover: #aab2bf;
  --text: #1b2027;
  --text-muted: #5c6675;
  --text-faint: #8b93a1;
  --accent: #2563d4;
  --accent-soft: #e6effc;
  --on-accent: #fff;
  --ok: #1c7a4c;
  --warn: #8a6210;
  --rule: rgba(37, 99, 212, 0.11);
  --who-a: #d8456c;
  --who-b: #2563d4;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  overflow-x: hidden;
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}

/* One language at a time. The attribute is the switch, so nothing has to be
   swapped in JavaScript and the markup stays honest about what it contains. */
:root[data-locale='ru'] [lang='en'],
:root[data-locale='en'] [lang='ru'] {
  display: none;
}

/* --- background -----------------------------------------------------------
 *
 * The page sits on the grid a terminal draws on: cells at the proportions of a
 * monospace character — narrow and tall, never square, which is the whole
 * difference between this and graph paper — ruled at the edge of visibility.
 *
 * Two repeating gradients on one element: no blur, no blobs, no elements, and
 * nothing that moves. A background that animates is a background the reader
 * notices twice, and it has nothing to say the second time. */

.lattice {
  --cell-w: 9px;
  --cell-h: 26px;

  position: absolute;
  inset: 0 0 auto 0;
  height: min(1080px, 125vh);
  pointer-events: none;
  z-index: 0;

  background-image:
    repeating-linear-gradient(to right, var(--rule) 0 1px, transparent 1px var(--cell-w)),
    repeating-linear-gradient(to bottom, var(--rule) 0 1px, transparent 1px var(--cell-h));

  /* Faded outward from the top left, where the headline is: the grid is a
     texture under the words and gone before anything has to be scrolled past. */
  -webkit-mask-image: radial-gradient(115% 85% at 8% 4%, #000 0%, transparent 66%);
  mask-image: radial-gradient(115% 85% at 8% 4%, #000 0%, transparent 66%);
}

/* --- chrome --------------------------------------------------------------- */

.topbar,
main,
.footer {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px clamp(16px, 5vw, 56px);
  max-width: 1180px;
  margin: 0 auto;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: inherit;
  text-decoration: none;
  font-size: 17px;
}

.mark {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.nav {
  display: none;
  gap: 22px;
  margin-inline: auto;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 15px;
  transition: color 0.15s;
}

.nav a:hover {
  color: var(--text);
}

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

.ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 7px;
  min-width: 34px;
  height: 32px;
  padding: 0 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.ghost:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

/* --- buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-panel);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 0.15s,
    border-color 0.15s,
    box-shadow 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-hover);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  box-shadow: 0 10px 26px -10px var(--accent);
}

.btn-quiet {
  background: none;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 14px 26px;
  font-size: 16px;
}

/* --- hero ----------------------------------------------------------------- */

.hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(28px, 7vw, 72px) clamp(16px, 5vw, 56px) clamp(40px, 8vw, 96px);
  display: grid;
  gap: clamp(36px, 6vw, 64px);
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  font-size: clamp(30px, 6.4vw, 54px);
  font-weight: 680;
}

.lede {
  color: var(--text-muted);
  font-size: clamp(16px, 2.4vw, 18px);
  max-width: 56ch;
  margin: 20px 0 28px;
}

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.fineprint {
  margin: 18px 0 0;
  font-size: 14px;
  color: var(--text-faint);
}

/* --- the room, animated --------------------------------------------------- */

.stage {
  position: relative;
  perspective: 1400px;
}

/* Behind the window, two outlines a little off true, in the colours the room
   gives the two people in it. The same file from two sides — which is the whole
   product — instead of a coloured cloud, which is every product.
 *
 * Sideways only where there is room for it. On one column the mock already
 * reaches the page's margins, so the offset goes vertical and the frames stack
 * rather than pushing a scrollbar onto the page. */
.stage-glow {
  --slip-x: 0px;
  --slip-y: 9px;
  position: absolute;
  inset: 0;
  z-index: -1;
}

.stage-glow::before,
.stage-glow::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid;
  border-radius: 14px;
}

.stage-glow::before {
  border-color: color-mix(in srgb, var(--who-b) 38%, transparent);
  transform: translate(var(--slip-x), var(--slip-y));
}

.stage-glow::after {
  border-color: color-mix(in srgb, var(--who-a) 30%, transparent);
  transform: translate(calc(var(--slip-x) * -1), calc(var(--slip-y) * -1));
}

.window {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-raised);
  overflow: hidden;
  box-shadow: 0 40px 80px -50px rgba(0, 0, 0, 0.9);
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px) rotateX(6deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.chrome {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-hover);
}

.chrome-title {
  margin-left: 10px;
  font-size: 12px;
  color: var(--text-faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pill {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid;
  white-space: nowrap;
}

.pill-live {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
}

.panes {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 178px;
}

.tree {
  display: none;
  margin: 0;
  padding: 14px 10px;
  list-style: none;
  border-right: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.tree li {
  padding: 3px 6px;
  border-radius: 5px;
  white-space: nowrap;
}

.tree .indent {
  padding-left: 18px;
}

.tree .active {
  background: var(--accent-soft);
  color: var(--text);
}

.code {
  /* Who is who: the candidate writes, the interviewer picks. The two colours
     are the page's, because the stage behind this window uses them too. */
  --pick: color-mix(in srgb, var(--who-b) 24%, transparent);
  padding: 14px clamp(12px, 3vw, 18px);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(11px, 2.6vw, 13px);
  line-height: 2;
  overflow: hidden;
}

.code .line {
  position: relative;
  /* pre, not nowrap: the indentation is half of what makes it read as code. */
  white-space: pre;
}

.code em {
  color: var(--accent);
  font-style: normal;
}
.code b {
  color: var(--warn);
  font-weight: 500;
}
.code u {
  color: var(--ok);
  text-decoration: none;
}

/* --- the sequence ---------------------------------------------------------
 *
 * Four beats, in the order an interview actually goes: the candidate writes a
 * line, the interviewer selects the line the candidate wrote, the candidate
 * replaces it, and only then does the terminal run what is now there.
 *
 * Everything below shares one 8s timeline, so the beats cannot drift apart,
 * and nothing repeats — a page that blinks at you is harder to read than one
 * that holds still.
 *
 * The widths are in ch because the font is monospace: 48 and 37 are the
 * character counts of the two versions of the line, so the reveal stops on the
 * last glyph instead of somewhere in the empty half of the row. Change the
 * text, change the number. */
.edit .was,
.edit .now {
  display: inline-block;
  vertical-align: bottom;
  overflow: hidden;
  white-space: pre;
  width: 0;
}

.edit .was {
  /* The selection sweeps across this span and nothing else, so what lights up
     is the line, not the whole row. */
  background-image: linear-gradient(var(--pick), var(--pick));
  background-repeat: no-repeat;
  background-size: 0 100%;
  animation: wrote 8s linear both;
}

.edit .now {
  animation: rewritten 8s linear both;
}

@keyframes wrote {
  0%,
  7% {
    width: 0;
    background-size: 0 100%;
    animation-timing-function: steps(25, end);
  }
  28%,
  38% {
    width: 25ch;
    background-size: 0 100%;
  }
  47%,
  63% {
    width: 25ch;
    background-size: 100% 100%;
  }
  68% {
    width: 25ch;
    background-size: 0 100%;
    animation-timing-function: steps(25, end);
  }
  80%,
  100% {
    width: 0;
    background-size: 0 100%;
  }
}

@keyframes rewritten {
  0%,
  80% {
    width: 0;
    animation-timing-function: steps(22, end);
  }
  98%,
  100% {
    width: 22ch;
  }
}

/* Solid, and it stays where the typing stopped. */
.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  vertical-align: text-bottom;
  margin-left: 1px;
  background: var(--who-a);
  opacity: 0;
  animation: caret-in 8s linear both;
}

@keyframes caret-in {
  0% {
    opacity: 0;
  }
  5%,
  38% {
    opacity: 1;
  }
  /* The interviewer has the line; the candidate's cursor waits. */
  44%,
  63% {
    opacity: 0.2;
  }
  70%,
  100% {
    opacity: 1;
  }
}

/* Two people in one file: the name is the point, not the cursor. The name and
   nothing else, because that is all a remote cursor carries in the editor —
   the role is shown once, in the presence chips above it. Both labels sit in
   the same spot, since they are never on screen together. */
.marks {
  position: relative;
  display: inline-block;
  width: 0;
}

.marks i {
  position: absolute;
  /* Hanging off the cursor into the blank row below it, growing rightwards —
     the one direction with nothing in it at any point in the sequence. */
  top: 100%;
  left: -2px;
  margin-top: 1px;
  padding: 1px 7px;
  border-radius: 0 0 5px 5px;
  font-style: normal;
  font-size: 10px;
  line-height: 1.6;
  white-space: nowrap;
  color: #fff;
  opacity: 0;
}

.mark-a {
  background: var(--who-a);
  animation: mark-a 8s linear both;
}

.mark-b {
  background: var(--who-b);
  animation: mark-b 8s linear both;
}

@keyframes mark-a {
  0%,
  4% {
    opacity: 0;
  }
  9%,
  33% {
    opacity: 1;
  }
  38%,
  66% {
    opacity: 0;
  }
  71%,
  100% {
    opacity: 1;
  }
}

@keyframes mark-b {
  0%,
  36% {
    opacity: 0;
  }
  41%,
  62% {
    opacity: 1;
  }
  67%,
  100% {
    opacity: 0;
  }
}

.term {
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 12px clamp(12px, 3vw, 18px);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(10.5px, 2.5vw, 12.5px);
  line-height: 1.9;
  color: var(--text-muted);
}

.term-line {
  opacity: 0;
  animation: appear 0.3s ease forwards;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt {
  color: var(--ok);
}

/* After the rewrite, not during it: the run is the last beat of the sequence
   above, which finishes at 7.8s. */
.t1 {
  /* Visible from the start — it is the prompt the command gets typed at. */
  animation: none;
  opacity: 1;
}

.cmd {
  display: inline-block;
  vertical-align: bottom;
  overflow: hidden;
  white-space: pre;
  width: 0;
  animation: run 1.1s steps(19, end) 8.1s both;
}

@keyframes run {
  to {
    width: 19ch;
  }
}

/* Hands the cursor over to the next prompt once the command has been sent. */
.cursor-idle {
  animation: handover 0.1s linear 9.5s both;
}

@keyframes handover {
  to {
    opacity: 0;
  }
}
.t2 {
  animation-delay: 9.3s;
}
.t3 {
  animation-delay: 9.6s;
  /* The number the fix was for. Offline and holdout now agree. */
  color: var(--ok);
}
.t4 {
  animation-delay: 10s;
}

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.cursor {
  display: inline-block;
  width: 7px;
  height: 1em;
  background: var(--text-muted);
  vertical-align: text-bottom;
}

/* --- sections ------------------------------------------------------------- */

.section {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(44px, 8vw, 88px) clamp(16px, 5vw, 56px);
}

.section h2 {
  font-size: clamp(24px, 4.4vw, 36px);
  margin-bottom: 12px;
}

.section-lede {
  color: var(--text-muted);
  max-width: 62ch;
  margin: 0 0 28px;
}

/* Revealed on the way in. Hiding is deliberately conditional on `.reveals`,
   which main.js puts on the document once it knows it can put things back: the
   markup carries `.reveal` from the server, so hiding it unconditionally would
   mean a page with no working script is a hero and nothing else. */
.reveals .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.6s cubic-bezier(0.2, 0.7, 0.3, 1),
    transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.reveals .reveal.shown {
  opacity: 1;
  transform: none;
}

/* --- steps ---------------------------------------------------------------- */

.steps {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: grid;
  gap: 18px;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 22px 22px 22px 62px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  transition: border-color 0.2s;
}

.steps li:hover {
  border-color: var(--border-hover);
}

.num {
  position: absolute;
  left: 20px;
  top: 21px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}

.steps h3 {
  font-size: 17px;
  margin-bottom: 6px;
}

.steps p,
.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

/* --- feature grid --------------------------------------------------------- */

.grid {
  display: grid;
  gap: 18px;
}

.card {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  transition:
    transform 0.2s,
    border-color 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
}

.card h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

/* --- languages ------------------------------------------------------------ */

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chips li {
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-muted);
  background: var(--bg-panel);
  transition:
    color 0.15s,
    border-color 0.15s,
    transform 0.15s;
}

.chips li:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.chip-any {
  border-style: dashed;
  color: var(--accent);
}

/* --- plans ---------------------------------------------------------------- */

.plans {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.plan {
  position: relative;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-panel);
}

.plan-featured {
  border-color: var(--accent);
  box-shadow: 0 24px 60px -40px var(--accent);
}

.ribbon {
  position: absolute;
  top: -11px;
  left: 26px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--on-accent);
}

.plan h3 {
  font-size: 19px;
}

.price {
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.03em;
  margin: 8px 0 18px;
}

.plan ul {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.plan li {
  position: relative;
  padding-left: 24px;
  font-size: 15px;
  color: var(--text-muted);
}

.plan li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--ok);
}

.plan li.off::before {
  content: '·';
  color: var(--text-faint);
  font-weight: 700;
}

/* --- closing and footer --------------------------------------------------- */

.closing {
  text-align: center;
}

.closing p {
  color: var(--text-muted);
  margin: 12px 0 26px;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 30px clamp(16px, 5vw, 56px) 44px;
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
  font-size: 14px;
}

.footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
}

.footer a:hover {
  color: var(--text);
}

.footer .muted {
  color: var(--text-faint);
  margin: 0;
  max-width: 60ch;
}

.wordmark.small {
  font-size: 15px;
}

/* --- wider screens -------------------------------------------------------- */

@media (min-width: 720px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
  /* Three cards over two columns leave one alone on a second row. Letting the
     last one take the full width reads as a decision rather than a leftover. */
  .grid > :last-child {
    grid-column: 1 / -1;
  }
  .steps {
    grid-template-columns: repeat(2, 1fr);
  }
  .plans {
    grid-template-columns: repeat(2, 1fr);
    max-width: 780px;
  }
  .panes {
    grid-template-columns: 150px 1fr;
  }
  .tree {
    display: block;
  }
  .footer {
    grid-template-columns: auto 1fr;
    align-items: center;
  }
  .footer .muted {
    grid-column: 1 / -1;
  }
}

@media (min-width: 980px) {
  .nav {
    display: flex;
  }
  .hero {
    grid-template-columns: 1.05fr 1fr;
    align-items: center;
  }
  /* Two columns: the mock no longer fills the width, so the frames behind it
     have somewhere to slip sideways. */
  .stage-glow {
    --slip-x: 9px;
  }
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
  /* Three columns for three cards: the widening above is no longer needed. */
  .grid > :last-child {
    grid-column: auto;
  }
  .steps {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Somebody who asked for less motion gets the page, not the show. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  /* The sequence's last frame, without the sequence: the line as the candidate
     left it, and the run that followed. */
  .edit .was {
    display: none;
  }
  .edit .now {
    width: 22ch;
  }
  .caret,
  .mark-a,
  .term-line {
    opacity: 1;
  }
  .mark-b {
    opacity: 0;
  }
  /* Specific enough to beat `.reveals .reveal` above, for the case where the
     preference is turned on after the class was already set. */
  .reveals .reveal {
    opacity: 1;
    transform: none;
  }
}
