
/* ---- Fonts (bundled in ../fonts; local() is used when already installed) -- */
@font-face {
  font-family: "Chicago";
  src: local("Chicago"), local("ChicagoFLF"),
       url("../fonts/ChicagoFLF.woff2") format("woff2"),
       url("../fonts/ChicagoFLF.woff") format("woff");
  font-display: swap;
}
@font-face {
  font-family: "Geneva";
  src: local("Geneva"),
       url("../fonts/FindersKeepers.woff2") format("woff2"),
       url("../fonts/FindersKeepers.woff") format("woff");
  font-display: swap;
}
@font-face {
  font-family: "Monaco";
  src: local("Monaco"),
       url("../fonts/monaco.woff2") format("woff2"),
       url("../fonts/monaco.woff") format("woff");
  font-display: swap;
}

:root {
  /* The duotone: --ink is the accent (rewritten live by the ink picker),
     --ink-deep an auto-darkened version for body text and frames.
     --black/--white are aliases so every rule follows the duotone. */
  --paper:    #ffffff;
  --ink:      #1d0f3a;
  --ink-deep: #1d0f3a;
  --hl:       var(--ink);   /* selection / hover highlight fill */

  --black: var(--ink-deep);
  --white: var(--paper);

  /* Type roles: Chicago = chrome, Geneva = labels/body, Monaco = numbers */
  --font-chrome: "Chicago", "Geneva", "Helvetica Neue", sans-serif;
  --font-label:  "Geneva", "Helvetica Neue", Arial, sans-serif;
  --font-mono:   "Monaco", "Courier New", monospace;
  --font-body:   var(--font-label);

  /* Content text sizes — scaled per device in the @media blocks at the end.
     (The Chicago chrome is sized separately and left crunchy.) */
  --fs-body:  14px;   /* document / lyrics body */
  --fs-list:  16px;   /* tracklists */
  --fs-label: 13px;   /* desktop icon labels, album & story titles */
  --fs-micro: 11px;   /* album years, "Soon" */
  --fs-h1:    19px;   /* window headings */

  /* Metrics */
  --titlebar-h: 19px;
  --menubar-h: 20px;
  --scroll: 15px;          /* scrollbar thickness */
  --frame: 1px;            /* hairline frame      */

  /* "Gray" is never a real gray — it's this 2px ink/paper checkerboard. */
  --dither: repeating-conic-gradient(var(--ink) 0% 25%, var(--paper) 0% 50%);
  --dither-size: 2px 2px;

  /* The menu logo: the lostform blob as a mask, so it renders in the current
     ink (and flips to paper on highlight) instead of its amber color. */
  --lostform-mask: url("../assets/icons/lostform.png");
}

/* ---- Reset & crisp rendering -------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.25;
  color: var(--black);
  background-color: var(--white);
  background-image: var(--dither);
  background-size: var(--dither-size);
  /* Bitmap fonts near native size: smoothing off reads crisp, not skeletal. */
  -webkit-font-smoothing: none;
  image-rendering: pixelated;       /* keeps the dithered surfaces crisp */
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}

/* Suppress iOS Safari's double-tap zoom on controls (two quick taps on ink
   swatches were zooming the page). Scrolling and pinch-zoom still work. */
.swatch, .menu-trigger, .menu-dropdown a, .menu-dropdown button,
.desktop-icon, .btn, .close-box, .album, .story, .tracklist button,
.scroll-arrow, .scroll-track, .link, .title-bar {
  touch-action: manipulation;
}

/* Utility: the canonical 50% dither, reusable anywhere. */
.dither {
  background-color: var(--white);
  background-image: var(--dither);
  background-size: var(--dither-size);
}

/* ---- Menu bar ------------------------------------------------------------ */
.menu-bar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--menubar-h);
  background: var(--white);
  border-bottom: var(--frame) solid var(--black);
  font-family: var(--font-chrome);
  font-size: 12px;
  z-index: 1000;
}
.menu-root {
  display: flex;
  align-items: stretch;
  height: 100%;
  margin: 0;
  padding: 0 6px;
  list-style: none;
}

.menu-item {
  position: relative;        /* anchor for the dropdown */
  display: flex;
}

.menu-trigger {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  white-space: nowrap;
  cursor: default;
}
.menu-trigger:hover,
.menu-item.is-open > .menu-trigger {
  background: var(--hl);
  color: var(--white);
}

.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  display: none;
  z-index: 10;
  min-width: 150px;
  margin: 0;
  padding: 2px 0;
  list-style: none;
  font-weight: 400;
  background: var(--paper);
  border: var(--frame) solid var(--ink-deep);
  box-shadow: 2px 2px 0 0 var(--ink-deep);
}
.menu-item.is-open .menu-dropdown { display: block; }
.menu-dropdown a,
.menu-dropdown button {
  display: block;
  width: 100%;
  padding: 2px 20px 2px 14px;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--ink-deep);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.menu-dropdown a:hover,
.menu-dropdown button:hover { background: var(--hl); color: var(--paper); }
/* Non-interactive dropdown text (e.g. the contact address): no hover, selectable. */
.menu-dropdown .menu-static {
  padding: 2px 14px;
  color: var(--ink-deep);
  white-space: nowrap;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
}

/* The lostform menu logo, masked so it inverts to paper when highlighted. */
.lostform .menu-trigger {
  width: 26px;
  padding: 0;
  justify-content: center;
}
.lostform .menu-trigger::before {
  content: "";
  width: 18px;
  height: 18px;
  background: var(--ink);
  -webkit-mask: var(--lostform-mask) center / contain no-repeat;
          mask: var(--lostform-mask) center / contain no-repeat;
  image-rendering: auto;    /* smooth downscale of the blob, not pixelated */
}
.lostform .menu-trigger:hover::before,
.lostform.is-open .menu-trigger::before { background: var(--paper); }

/* ---- Windows ------------------------------------------------------------- */
.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 120px;
  /* Grow to content, but never past the screen (then the content scrolls). */
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 28px);
  background: var(--white);
  border: var(--frame) solid var(--black);
  box-shadow: 1px 1px 0 0 var(--black);
}

/* Title bar: horizontal racing stripes with a white lozenge for the title. */
.title-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--titlebar-h);
  flex-shrink: 0;            /* never let a fixed-height (mobile) window squeeze the bar */
  padding: 0 4px;
  border-bottom: var(--frame) solid var(--black);
  background-image: repeating-linear-gradient(
    to bottom, var(--ink) 0 1px, var(--paper) 1px 2px);
  background-position: 0 2px;       /* small margin top/bottom from the lines */
  background-size: 100% calc(100% - 4px);
  background-repeat: no-repeat;
  font-family: var(--font-chrome);
  font-size: 12px;
  cursor: default;
}
.title-bar .title {
  background: var(--white);
  padding: 0 7px;
  max-width: calc(100% - 44px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Close box: a white square interrupting the stripes, X masked on top. */
.close-box {
  position: absolute;
  top: 50%;
  left: 7px;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  background: var(--paper);
  cursor: default;
}
.close-box::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--black);
  -webkit-mask: url("../assets/icons/x.png") center / contain no-repeat;
          mask: url("../assets/icons/x.png") center / contain no-repeat;
  image-rendering: auto;
}
/* Hover accent only on real pointers — on touch, a tap leaves a sticky :hover
   on the box revealed underneath, which looked like a stuck accent color. */
@media (hover: hover) {
  .close-box:hover::before { background: var(--ink); }
}

/* Desktop (above the drill-down breakpoint): title bars drag (grab/grabbing),
   the close box clicks (pointer). Placed AFTER the base .title-bar/.close-box
   rules — same specificity, so source order decides who wins. */
@media (min-width: 1201px) {
  .title-bar { cursor: grab; }
  .title-bar:active { cursor: grabbing; }
  .close-box { cursor: pointer; }
}

/* Inactive window: blank title bar, hidden close box. */
.window.inactive { box-shadow: none; }
.window.inactive .title-bar { background-image: none; }
.window.inactive .title { color: var(--black); }
.window.inactive .close-box { display: none; }

/* The pane is a grid so scrollbars hug the right/bottom edges. */
.window-pane {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 1fr auto;
  min-height: 0;
}
.window-pane > .content {
  grid-column: 1;
  grid-row: 1;
  overflow: auto;
  padding: 10px 12px;
  min-height: 0;
}
/* Native scrollbars hidden; our chrome stands in. Wheel/trackpad still works. */
.window-pane > .content { scrollbar-width: none; }
.window-pane > .content::-webkit-scrollbar { width: 0; height: 0; }

/* ---- Scrollbars (built and wired up by newVisionVirtual.js) -------------- */
.scroll-v, .scroll-h {
  display: flex;
  background-color: var(--white);
  background-image: var(--dither);
  background-size: var(--dither-size);
}
.scroll-v {
  grid-column: 2; grid-row: 1;
  flex-direction: column;
  width: var(--scroll);
  border-left: var(--frame) solid var(--black);
}
.scroll-h {
  grid-column: 1; grid-row: 2;
  height: var(--scroll);
  border-top: var(--frame) solid var(--black);
}
.scroll-corner {
  grid-column: 2; grid-row: 2;
  width: var(--scroll); height: var(--scroll);
  background: var(--white);
  border-left: var(--frame) solid var(--black);
  border-top: var(--frame) solid var(--black);
}
/* Arrows are SVG images (assets/icons/arrow-*.svg), sized by the files
   themselves and grid-centered — no font metrics involved. */
.scroll-arrow {
  flex: 0 0 var(--scroll);
  display: grid;
  place-items: center;
  background: var(--white);
}
.scroll-arrow img { display: block; }
.scroll-v .scroll-arrow { border-bottom: var(--frame) solid var(--black); }
.scroll-v .scroll-arrow:last-child {
  border-bottom: 0; border-top: var(--frame) solid var(--black);
}
.scroll-h .scroll-arrow { border-right: var(--frame) solid var(--black); }
.scroll-h .scroll-arrow:last-child {
  border-right: 0; border-left: var(--frame) solid var(--black);
}
.scroll-track {
  position: relative;          /* anchor for the absolutely-positioned thumb */
  flex: 1 1 auto;
  overflow: hidden;
}
.scroll-thumb {
  position: absolute;
  background: var(--white);
  border: var(--frame) solid var(--black);
}
/* JS sets the scroll-axis size + offset; the cross axis fills the gutter. */
.scroll-v .scroll-thumb { left: 0; right: 0; top: 0; }
.scroll-h .scroll-thumb { top: 0; bottom: 0; left: 0; }

/* ---- Document typography (wrap body copy in .doc) ------------------------ */
.doc { font-family: var(--font-body); font-size: var(--fs-body); line-height: 1.4; }
.doc h1 {
  font-weight: 700;
  margin: 0 0 .35em;
  line-height: 1.1;
  font-size: var(--fs-h1);
  border-bottom: 2px solid var(--black);
  padding-bottom: 3px;
}
.doc p { margin: 0 0 .7em; }

/* ---- Hyperlinks ----------------------------------------------------------- */
/* The marker glyph is drawn in currentColor so it flips with the link. */
.marker {
  display: inline-block;
  width: 13px;
  height: 9px;
  margin: 0 2px;
  vertical-align: 0;
  background: var(--paper);
  border: var(--frame) solid currentColor;
  position: relative;
}
.marker::after {
  content: "";
  position: absolute;
  left: 1px; right: 1px; top: 2px;
  border-top: var(--frame) solid currentColor;
  box-shadow: 0 2px 0 0 currentColor;   /* second line: the "lines of text" look */
}

a.link, .link {
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
a.link:hover, .link:hover { background: var(--hl); color: var(--paper); }

/* ---- Form controls -------------------------------------------------------- */
.field {
  font-family: var(--font-chrome);
  font-size: 12px;
  background: var(--white);
  border: var(--frame) solid var(--black);
  padding: 2px 4px;
  min-width: 60px;
}
.field:focus { outline: none; }

.btn {
  display: inline-block;
  font-family: var(--font-chrome);
  font-size: 12px;
  background: var(--white);
  color: var(--black);
  border: var(--frame) solid var(--black);
  border-radius: 9px;
  padding: 2px 14px;
  text-decoration: none;
  cursor: default;
}
.btn:hover { background: var(--hl); color: var(--white); }
.btn:active { background: var(--hl); color: var(--white); }
/* Default button: the bold ring (white gap + black ring) around it. */
.btn.default { box-shadow: 0 0 0 1px var(--white), 0 0 0 3px var(--black); }
/* Disabled button (e.g. store links that don't exist yet): dimmed, inert. */
.btn.disabled { opacity: .45; pointer-events: none; }

/* ---- Ink picker (behavior in newVisionVirtual.js) ------------------------- */
.ink-picker {
  position: fixed;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--paper);
  border: var(--frame) solid var(--ink-deep);
  box-shadow: 1px 1px 0 0 var(--ink-deep);
  z-index: 1000;
}
.swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: var(--frame) solid var(--ink-deep);
  cursor: pointer;
  /* fill comes from inline style / data-ink so it shows even before JS runs */
}
.swatch:hover { box-shadow: 0 0 0 1px var(--paper); }
.swatch.active { box-shadow: 0 0 0 1px var(--paper), 0 0 0 2px var(--ink-deep); }

/* ---- Desktop & icons ------------------------------------------------------ */
.desktop {
  position: fixed;
  left: 0; right: 0;
  top: var(--menubar-h);
  bottom: 0;
}
.icons {
  position: absolute;
  top: 16px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.desktop-icon {
  width: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-label);
  font-size: var(--fs-label);
  color: var(--ink-deep);
  text-align: center;
}
.desktop-icon .glyph {
  width: 46px;
  height: 40px;
  display: block;
}
.desktop-icon .glyph img { width: 100%; height: 100%; display: block; }
.desktop-icon .label {
  padding: 0 4px;
  background: var(--paper);
  line-height: 1.15;
}
.desktop-icon:hover .label { background: var(--hl); color: var(--paper); }

/* ---- Album browser & detail ----------------------------------------------- */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, 96px);
  gap: 18px 16px;
  justify-content: center;
  font-family: var(--font-label);
}
/* A shelf tile is a real <button>; reset the chrome, keep the layout. */
.album {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: center;
}
.cover {
  object-fit: cover;
  border: var(--frame) solid var(--ink-deep);
  image-rendering: auto;                 /* photos: smooth, not pixelated */
  filter: grayscale(1) contrast(1.18) brightness(1.02);
}
.album .cover { width: 84px; height: 84px; }
.album .album-title { font-size: var(--fs-label); line-height: 1.2; max-width: 92px; }
.album .album-year { font-size: var(--fs-micro); font-family: var(--font-mono); }
.album:hover .album-title { background: var(--hl); color: var(--paper); }

.album-detail { display: flex; gap: 16px; align-items: flex-start; }
.album-detail .cover { width: 168px; height: 168px; flex: 0 0 auto; }
.album-detail .meta { min-width: 0; }
.album-detail .album-year { font-family: var(--font-mono); font-size: var(--fs-body); margin: 0 0 .6em; }
.album-detail .actions { display: flex; gap: 8px; margin: 0 0 .8em; }

.tracklist {
  list-style: none;
  counter-reset: track;
  margin: .2em 0 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: var(--fs-list);
}
.tracklist li { counter-increment: track; white-space: nowrap; }
.tracklist li::before {
  content: counter(track, decimal-leading-zero) "  ";
  font-family: var(--font-mono);
  font-size: 0.8em;
}
/* Each track is a <button> that opens its lyrics, restyled as a hyperlink. */
.tracklist button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  text-align: left;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.tracklist button:hover { background: var(--hl); color: var(--paper); }
.tracklist .nolyric { color: var(--ink-deep); }

/* ---- Stories --------------------------------------------------------------- */
.shelf--stories {
  grid-template-columns: repeat(auto-fill, 116px);
  justify-content: center;
}
.story {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: center;
}
.story-cover {
  object-fit: cover;
  border: var(--frame) solid var(--ink-deep);
  image-rendering: auto;
  filter: grayscale(1) contrast(1.18) brightness(1.02);
}
.story .story-cover { width: 108px; height: 150px; }
.story .story-title { font-size: var(--fs-label); line-height: 1.2; max-width: 112px; }
.story .story-soon { font-size: var(--fs-micro); font-family: var(--font-mono); }
.story:hover .story-title { background: var(--hl); color: var(--paper); }

.album-detail .story-cover { width: 150px; height: 210px; flex: 0 0 auto; }
.story-desc { margin-top: .3em; }

/* ---- Lyrics ----------------------------------------------------------------
   Keyed off .song-lyrics-container so the same rules style both in-window
   lyrics and the standalone /lyrics/<album>/<song>.html pages. */
.song-lyrics-container .verse,
.song-lyrics-container .chorus,
.song-lyrics-container .bridge,
.song-lyrics-container .pre-chorus { margin: 0 0 1.1em; font-style: normal; padding-left: 0; border-left: 0; }
.song-lyrics-container p { margin: 0; line-height: 1.3; }

audio { width: 100%; filter: grayscale(1); }

/* Pre-dithered 1-bit portrait in the About window; pixelated keeps dots crisp. */
.about-photo {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  border: var(--frame) solid var(--ink-deep);
  margin-bottom: 10px;
}

/* ---- Phones & tablets: drill-down mode ------------------------------------
   One near-full-screen window at a time; closing the top window reveals the
   one beneath (= back). The window manager writes inline left/top/width, so
   these overrides need !important to win. */
@media (max-width: 1200px) {
  :root {
    --fs-body: 18px;
    --fs-list: 19px;
    --fs-label: 16px;
    --fs-micro: 13px;
    --fs-h1: 25px;
  }
  .icons { right: 6px; }
  .window {
    left: 12px !important;
    top: calc(var(--menubar-h) + 18px) !important;
    width: calc(100% - 24px) !important;     /* 100% of body, not 100vw — iOS-safe */
    height: calc(100% - var(--menubar-h) - 36px) !important;
    max-width: none;
    max-height: none;
  }
  /* long titles should wrap, not force a horizontal scrollbar */
  .tracklist li { white-space: normal; }

  /* No arrow buttons on touch — you swipe to scroll; the bar is just a
     position indicator. The track stretches to fill the freed space. */
  .scroll-arrow { display: none; }

  /* Child windows (album/lyric/story): closing pops back to the parent,
     so the close box becomes a BACK arrow. Top-level windows keep the X. */
  .window--back .close-box::before {
    -webkit-mask-image: url("../assets/icons/back.png");
            mask-image: url("../assets/icons/back.png");
  }
}

/* Phones: larger text still, and stack the detail views — side-by-side would
   squeeze the tracklist into a sliver. Header centered, tracklist left. */
@media (max-width: 640px) {
  :root {
    --fs-body: 20px;
    --fs-list: 21px;
    --fs-label: 18px;
    --fs-micro: 14px;
    --fs-h1: 28px;
  }
  .album-detail { flex-direction: column; align-items: center; }
  .album-detail .meta { width: 100%; }
  .album-detail h1,
  .album-detail .album-year { text-align: center; }
  .album-detail .actions { justify-content: center; }
}

/* Very large screens: bump content text so it isn't tiny to read. */
@media (min-width: 1680px) {
  :root {
    --fs-body: 16px;
    --fs-list: 17px;
    --fs-label: 14px;
    --fs-micro: 12px;
    --fs-h1: 22px;
  }
}
