@font-face { font-family: "Special Elite"; src: url("engine/fonts/SpecialElite-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: url("engine/fonts/CourierPrime-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: url("engine/fonts/CourierPrime-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* TidyType landing: one screen, no scroll. A typewriter under a desk lamp in a dark room;
   the sheet in it is a live text box; benefits float on glass index cards either side. */

:root {
  --room: #1a1815;
  --ink: #e2d8c2;
  --ink-soft: #a99f89;
  --accent: #d2644e;
  --sheet: #e6dcc6;
  --sheet-ink: #26221e;
  --sheet-soft: #7a705f;
  --sheet-rule: #d3c8ad;
  --type: "Special Elite", "American Typewriter", "Courier Prime", monospace;
  --mono: "Courier Prime", "American Typewriter", "Courier New", monospace;

  /* Machine width drives everything in the centre column. */
  --tw: min(640px, 48vw, calc((100dvh - 120px) * .95));
  --th: calc(var(--tw) * 312 / 640);
  --floor: 2.4dvh;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; overflow: hidden; }

body {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr var(--tw) 1fr;
  background: var(--room);
  color: var(--ink);
  font: 14px/1.5 var(--mono);
  -webkit-font-smoothing: antialiased;
}

/* Desk-lamp light falling on the machine. */
.spot {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(42% 60% at 50% 72%, rgba(226, 190, 140, .16), transparent 70%),
    radial-gradient(70% 50% at 50% 0%, rgba(226, 216, 194, .05), transparent 70%);
}

/* Grain over everything, as one fixed layer. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: .22;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .9  0 0 0 0 .85  0 0 0 0 .75  0 0 0 1.4 -.55'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---- Top bar ---- */

.bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(18px, 3vw, 44px);
}
.mark { display: flex; align-items: baseline; gap: 10px; color: var(--ink); text-decoration: none; }
.mark-name { font: 22px/1 var(--type); letter-spacing: .02em; }
.mark-sub { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); }
.bar-right { display: flex; align-items: center; gap: 22px; }

.sound {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.sound input { position: absolute; opacity: 0; width: 0; height: 0; }
.sound .box::before { content: "[ ]"; }
.sound .box { position: relative; color: var(--ink-soft); }
.sound .box::after {
  content: "x";
  position: absolute;
  left: 50%;
  top: 0;
  translate: -50% 0;
  color: var(--accent);
  font-weight: 700;
  opacity: 0;
  transition: opacity .1s;
}
.sound input:checked ~ .box::after { opacity: 1; }
.sound input:checked ~ span:last-child { color: var(--ink); }
.sound input:focus-visible ~ .box { outline: 1px solid var(--accent); outline-offset: 3px; }

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px 12px;
  border-radius: 2px;
  background: var(--accent);
  color: #f6ecd9;
  font: 700 13px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: 0 2px 0 #8e3a2b, 0 10px 24px -12px rgba(210, 100, 78, .7);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.cta:hover { filter: brightness(1.07); }
.cta:active { transform: translateY(2px); box-shadow: 0 0 0 #8e3a2b; }

/* ---- Centre stage ---- */

.stage { position: relative; grid-column: 2; height: 100dvh; }

.machine {
  position: absolute;
  left: 0;
  bottom: var(--floor);
  width: var(--tw);
  height: var(--th);
  z-index: 2;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .45));
}
.machine svg { display: block; width: 100%; height: 100%; overflow: visible; }

.key .kp { transition: transform .05s; }
.key.down .kp { transform: translateY(2px); }
.key.down .cap { fill: url(#g-cap-down); }
.key text { font: 700 10px var(--mono); fill: #2a2622; pointer-events: none; }
.machine .kp { transition: transform .05s; }
.machine .striker { transition: transform .05s; transform-box: fill-box; transform-origin: center; }
.machine.hit .striker { transform: translateY(-4px); }

/* The sheet tucks in behind the roller (roller centre is 31/312 of the machine). */
.sheet {
  position: absolute;
  z-index: 1;
  left: 50%;
  width: calc(var(--tw) * .64);
  top: max(84px, 11dvh);
  bottom: calc(var(--floor) + var(--th) * (1 - 31 / 312));
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  padding: clamp(18px, 3.2dvh, 30px) 26px 30px 30px;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, .06), transparent 18%),
    var(--sheet);
  color: var(--sheet-ink);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 30px 60px -30px rgba(0, 0, 0, .6);
  animation: feed 1s cubic-bezier(.16, 1, .3, 1) both;
}
/* Paper fibre and a little foxing, on the sheet only. */
.sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: .5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .38  0 0 0 0 .26  0 0 0 1.2 -.45'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>");
}

.sheet-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--sheet-rule);
}
.letterhead { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--sheet-soft); }
.new-sheet {
  border: 0;
  background: none;
  padding: 0;
  color: var(--sheet-soft);
  font: 10px var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.new-sheet:hover { color: var(--accent); }

.headline {
  position: relative;
  margin: clamp(12px, 2.4dvh, 22px) 0 0;
  font: 400 clamp(26px, calc(var(--tw) * .062), 40px)/1.08 var(--type);
  letter-spacing: -.005em;
  color: var(--sheet-ink);
}
.headline span {
  display: inline-block;
  clip-path: inset(0 100% 0 0);
  animation: strike .9s steps(12, end) forwards;
}
.headline span:first-child { animation-delay: .7s; }
.headline span:last-child { animation-delay: 1.7s; color: #a8392a; }

.prompt {
  position: relative;
  margin: 10px 0 0;
  font-size: 12px;
  letter-spacing: .06em;
  color: var(--sheet-soft);
  opacity: 0;
  transition: opacity .4s;
}
.prompt.show { opacity: 1; }
.caret {
  display: inline-block;
  width: 7px;
  height: 13px;
  margin-left: 4px;
  vertical-align: -2px;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

.sheet-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  margin-top: 18px;
}

#paper {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  padding: 0;
  background: repeating-linear-gradient(transparent 0 25px, var(--sheet-rule) 25px 26px) local;
  color: var(--sheet-ink);
  font: 17px/26px var(--mono);
  caret-color: var(--accent);
  outline: none;
  scrollbar-width: none;
}
#paper::-webkit-scrollbar { display: none; }

/* Editor's marks in the margin: one line per fix. */
.notes {
  list-style: none;
  margin: 0;
  padding: 2px 0 0 12px;
  width: clamp(92px, calc(var(--tw) * .17), 118px);
  border-left: 1px dashed #c7a397;
  overflow: hidden;
  font: 11px/1.3 var(--mono);
  color: #a8392a;
}
.notes li {
  margin-bottom: 9px;
  animation: mark .35s cubic-bezier(.2, 1.3, .4, 1) both;
}
.notes li s { color: var(--sheet-soft); text-decoration-thickness: 1px; }
.notes li small { display: block; color: var(--sheet-soft); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.notes li:nth-child(n+4) { opacity: .45; }
.notes li:nth-child(n+6) { display: none; }

/* ---- Floating glass index cards ---- */

.cards {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(14px, 3dvh, 30px);
  padding: 96px clamp(16px, 2.6vw, 44px) 40px;
}
.cards-left { align-items: flex-end; }
.cards-right { align-items: flex-start; }

.card {
  width: min(280px, 100%);
  padding: 17px 19px 16px;
  border-radius: 4px;
  /* Mostly opaque so the text never fights the room behind it; the glass is the edge light. */
  background:
    repeating-linear-gradient(transparent 0 23px, rgba(226, 216, 194, .045) 23px 24px),
    linear-gradient(155deg, rgba(58, 52, 45, .92), rgba(36, 32, 28, .9) 70%);
  border: 1px solid rgba(226, 216, 194, .2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .12),
    0 22px 40px -22px rgba(0, 0, 0, .9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  translate: var(--x) 0;
  animation: float 7s ease-in-out var(--d) infinite;
}
.card h2 { margin: 0 0 6px; font: 400 19px/1.15 var(--type); color: #f3ead6; }
.card p { margin: 0; font-size: 13px; line-height: 1.5; color: #d2c8b0; }
.card .ex {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px dashed rgba(226, 216, 194, .26);
  font-size: 13px;
  color: #f3ead6;
}
.card .ex s { color: #a99f89; text-decoration-color: #e9806a; text-decoration-thickness: 1.5px; }
.card .ex b { font-weight: 700; }
.card kbd {
  font: 700 10px/1 var(--mono);
  padding: 2px 5px 3px;
  border: 1px solid #a99f89;
  border-radius: 2px;
  color: #d2c8b0;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.card .sites { display: flex; gap: 14px; }
.card .sites .mark { width: 20px; height: 20px; color: #e8dfca; }
.card.pro { border-color: rgba(233, 128, 106, .5); }

.legal {
  position: fixed;
  left: clamp(18px, 3vw, 44px);
  bottom: 14px;
  z-index: 30;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.legal a { color: #a99f89; text-underline-offset: 3px; }
.legal a:hover { color: var(--ink); }

/* ---- Motion ---- */

@keyframes feed { from { transform: translateY(30%); } to { transform: none; } }
@keyframes strike { to { clip-path: inset(0 0 0 0); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes mark { from { opacity: 0; transform: translateX(-6px) scale(1.1); } to { opacity: 1; transform: none; } }
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(var(--r)); }
  50% { transform: translateY(-9px) rotate(calc(var(--r) * .6)); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .card, .caret { animation: none; }
  .card { transform: rotate(var(--r)); }
  .headline span { animation: none; clip-path: none; }
}

/* ---- Short screens: lighter cards so all three fit ---- */

@media (max-height: 760px) {
  .cards { padding-top: 78px; padding-bottom: 20px; gap: 12px; }
  .card { padding: 12px 15px 11px; }
  .card h2 { font-size: 16px; margin: 0 0 3px; }
  .card p { font-size: 11.5px; }
  .card .ex { display: none; }
}

/* ---- Narrow screens: the machine and the sheet only ---- */

@media (max-width: 960px) {
  :root { --tw: min(560px, calc(100vw - 32px), calc((100dvh - 120px) * 1.25)); }
  body { grid-template-columns: 1fr var(--tw) 1fr; }
  .cards { display: none; }
  .legal { display: none; }
  .mark-sub, .sound span:last-child { display: none; }
}
@media (max-width: 520px) {
  .notes { display: none; }
  .sheet-body { grid-template-columns: 1fr; }
  .sheet { width: calc(var(--tw) * .82); padding: 16px 18px 26px; }
  .cta { padding: 10px 12px; font-size: 11px; }
  }
