/* ==========================================================================
   Linwood Technologies LLC
   A Commodore 64 boot screen, roughly to scale.

   Palette is the classic VICE/Pepto C64 blue set. The authentic light-blue
   on blue is only ~2.5:1 contrast, so body text uses a lightened lavender
   (6.3:1) and the true C64 light blue is reserved for decoration.
   ========================================================================== */

@font-face {
  font-family: 'Press Start 2P';
  src: url('../fonts/press-start-2p-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --screen: #40318d;        /* C64 blue      - screen background */
  --border: #7b71d6;        /* C64 lt. blue  - the TV border     */
  --fg: #c9c2ff;            /* body text     - 6.3:1 on screen   */
  --dim: #8e84db;           /* decoration only, never body text  */
  --link: #b8c76f;          /* C64 yellow    - 5.7:1 on screen   */
  --ok: #9ad284;            /* C64 lt. green - 5.9:1 on screen   */

  --shell: clamp(0.75rem, 4vw, 3rem);
}

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

html {
  background: var(--border);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: var(--shell);
  min-height: 100vh;
  background: var(--border);
  font-family: 'Press Start 2P', ui-monospace, 'Cascadia Mono', 'Segoe UI Mono',
    Menlo, Consolas, monospace;
  color: var(--fg);
}

::selection {
  background: var(--fg);
  color: var(--screen);
}

/* --------------------------------------------------------------------------
   The screen
   -------------------------------------------------------------------------- */

.screen {
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2.5rem);
  background: var(--screen);
  box-shadow: inset 0 0 6rem rgba(0, 0, 0, 0.28);

  /* Lets .boot size itself against the screen's content width. */
  container-type: inline-size;

  font-size: clamp(11px, 2.6vw, 14px);
  line-height: 2;
  letter-spacing: 0;
  overflow-wrap: break-word;
  hyphens: none;
}

/* Scanlines + a faint bloom. Purely decorative, never intercepts input. */
.crt::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.16) 0 1px,
    transparent 1px 3px
  );
}

/* --------------------------------------------------------------------------
   Boot sequence
   -------------------------------------------------------------------------- */

/* A real C64 screen is 40 columns wide, and Press Start 2P has an advance
   width of exactly 1em, so 40 columns == 40em. Shrink the boot block until
   40em fits the screen's content box; never grow past the body size. Without
   container query support this falls back to the inherited size and the two
   long banner lines simply wrap. */
.boot {
  margin: 0 0 2em;
  color: var(--fg);
  font-size: min(1em, 2.45cqi);
}

.boot .row {
  min-height: 2em;
  white-space: pre-wrap;
}

@supports (font-size: 1cqi) {
  .boot .row {
    white-space: pre;
  }
}

.boot .row.blank {
  min-height: 1.2em;
}

/* --------------------------------------------------------------------------
   Content
   -------------------------------------------------------------------------- */

h1,
h2,
h3 {
  font-size: 1em;
  font-weight: 400;
  margin: 0;
  line-height: 2;
}

h1 {
  color: #fff;
}

p {
  margin: 0 0 1.4em;
  max-width: 40ch;
}

.tagline {
  color: var(--fg);
  margin-bottom: 2em;
}

.rule {
  border: 0;
  border-top: 2px solid var(--dim);
  margin: 2em 0;
}

.block {
  margin: 0 0 2.5em;
}

.block > h2 {
  color: #fff;
  margin-bottom: 1em;
}

/* BASIC line numbers */
.ln {
  color: var(--dim);
  margin-right: 1ch;
}

/* --------------------------------------------------------------------------
   App listing
   -------------------------------------------------------------------------- */

.apps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.app {
  margin: 0 0 2.25em;
  padding-left: 1.5ch;
  border-left: 2px solid var(--dim);
}

.app:last-child {
  margin-bottom: 0;
}

.app h3 {
  color: #fff;
  margin-bottom: 0.5em;
}

.app .desc {
  color: var(--fg);
  margin-bottom: 0.8em;
}

.app .links {
  margin: 0;
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em 2ch;
}

/* --------------------------------------------------------------------------
   Links - hover and focus are C64 inverse video
   -------------------------------------------------------------------------- */

a {
  color: var(--link);
  text-decoration: none;
  padding: 0 0.25ch;
  margin: 0 -0.25ch;
}

a:hover,
a:focus-visible {
  background: var(--link);
  color: var(--screen);
  outline: none;
}

a:focus-visible {
  box-shadow: 0 0 0 2px var(--screen), 0 0 0 4px var(--fg);
}

a::before {
  content: '> ';
  color: inherit;
}

a.bare::before {
  content: none;
}

/* --------------------------------------------------------------------------
   Cursor
   -------------------------------------------------------------------------- */

.cursor {
  display: inline-block;
  width: 1ch;
  height: 1em;
  vertical-align: text-bottom;
  background: var(--fg);
  animation: blink 1s step-end infinite;
}

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

.ready {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   About page bits
   -------------------------------------------------------------------------- */

.portrait {
  display: block;
  width: clamp(8rem, 40vw, 12rem);
  height: auto;
  margin: 0;
  border: 2px solid var(--dim);
  image-rendering: pixelated;
  background: var(--screen);
}

.figure {
  margin: 0 0 2em;
}

.figure figcaption {
  color: var(--fg);
  font-size: 0.85em;
  margin-top: 0.8em;
}

dl.facts {
  margin: 0 0 2em;
}

dl.facts dt {
  color: var(--dim);
}

dl.facts dd {
  margin: 0 0 1.2em;
  max-width: 40ch;
}

/* --------------------------------------------------------------------------
   Skip hint (boot only)
   -------------------------------------------------------------------------- */

.skip-hint {
  position: fixed;
  right: var(--shell);
  bottom: var(--shell);
  z-index: 10000;
  font-size: clamp(9px, 2vw, 11px);
  color: var(--screen);
  background: var(--border);
  padding: 0.5em 0.75em;
  pointer-events: none;
}

.skip-hint[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   JS boot state. Set by an inline <head> script so there is no flash of
   fully-rendered content before boot.js takes over. If boot.js never runs,
   a 5s fallback timer in that same inline script removes this class.
   -------------------------------------------------------------------------- */

.js-boot [data-line],
.js-boot .content {
  opacity: 0;
}

/* RUN hands the screen over: boot.js hides the boot block and the page
   renders where it was. The fade is short enough to read as a screen being
   painted rather than as a web-page transition. */
.boot[hidden] {
  display: none;
}

.content {
  transition: opacity 140ms linear;
}

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

@media (prefers-reduced-motion: reduce) {
  .cursor {
    animation: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
