/* cardozo.cc — one screen: the CRDZC wordmark, centred. Each letter is a link. With WebGL a shader draws it
   as dots (see hero.js); the inline SVG underneath is the accessible version and the fallback. Visual
   direction borrowed in spirit (not code) from christendijoux.com.

   Two themes. --bg is the ground, --fg the dots/ink on it. The theme is set on <html data-theme> before the first
   paint (see index.html); with no JS it simply follows the system. */

:root {
  --bg: #000; /* true black: OLED pixels switch off between dots */
  --fg: #f2f2ee;

  --pad: clamp(16px, 2.8vw, 40px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fff; /* true white and true black: the exact inverse of the dark theme */
  --fg: #000;

  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #fff;
    --fg: #000;

    color-scheme: light;
  }
}

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  overflow: hidden; /* one screen: nothing scrolls, so a finger's drag is never taken for a scroll or a rubber-band */
  overscroll-behavior: none;
}

/* The page has no text to select, and a press-and-hold is a gesture of its own (the curtain). Without this a phone takes
   a held finger for a text selection (iOS "Look Up", Android's handles; ::selection paints in the text colour, a white
   edge on the dark theme), and a vertical drag for a scroll (the browser then cancels the pointer). The browser's own
   pinch zoom is off for the same reason: the screen stays fixed, and hover and touch answer in place of scroll and zoom. */
html,
body {
  touch-action: none; /* the page's own gestures (hero.js): a finger's drag brings the curtain; nothing scrolls, pans or zooms */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

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

:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.hero {
  touch-action: none;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  height: 100svh;
  padding: var(--pad);
  background: var(--bg);
  overflow: hidden;
}

.scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated; /* crisp cells when the canvas is upscaled on high-DPI screens */
  opacity: 0;
  transition: opacity 1.2s ease;
}

.gl .scene {
  opacity: 1;
}

/* ---------------------------------------------------------------- the logo
   Centred. The SVG is the real, accessible wordmark and the no-WebGL fallback; once WebGL is running
   the canvas draws it instead. */

.logo {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: clamp(190px, 39vw, 690px);
  margin: 0;
  line-height: 0;
  transform: translate(-50%, -50%);
}

.logo svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: hidden;
  fill: var(--fg);
}

.gl .logo svg {
  opacity: 0; /* the shader draws it; the SVG stays for layout, hit-testing, focus and screen readers */
}

.logo .lt {
  transform-box: fill-box;
  transform-origin: center; /* the letter's random orientation (mirrored or not), set by hero.js */
}

.logo path {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transition: transform 1.25s var(--ease);
}

.logo .lt:nth-child(2) path { transition-delay: 0.07s; }
.logo .lt:nth-child(3) path { transition-delay: 0.14s; }
.logo .lt:nth-child(4) path { transition-delay: 0.21s; }
.logo .lt:nth-child(5) path { transition-delay: 0.28s; }

/* ---------------------------------------------------------------- states
   .booting  → everything waits just off-stage.  .ready → it all settles in. */

.js.booting .logo path { transform: translateY(112%); }


/* ---------------------------------------------------------------- the theme switch
   A 44 px target in the top-right corner (the 22 px icon sits at --pad from the edges). With WebGL the shader draws the icon in dots (the SVG is invisible but
   stays for layout, hit-testing, focus and screen readers); without it the SVG is the icon. It waits for the build. */

.theme {
  position: absolute;
  top: calc(var(--pad) - 11px);
  right: calc(var(--pad) - 11px);
  z-index: 2;
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
}

.js .theme {
  display: grid;
  place-items: center;
}

.ready .theme {
  pointer-events: auto;
}

.theme svg {
  display: block;
  width: 22px;
  height: 22px;
}

/* a moon in the dark theme, a sun in the light one */
.theme .sun {
  display: none;
}

:root[data-theme="light"] .theme .moon {
  display: none;
}

:root[data-theme="light"] .theme .sun {
  display: block;
}

.gl .theme svg {
  opacity: 0;
}

.gl .theme:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- small screens */

/* a phone held upright: the wordmark nearly spans the screen (the margin is the page's own padding); held sideways it stays
   modest, as the screen is already wide */
@media (max-width: 699.98px) and (orientation: portrait) {
  .logo { width: calc(100vw - 2 * var(--pad)); }
}

@media (max-width: 699.98px) and (orientation: landscape) {
  .logo { width: 60vw; }
}

/* ---------------------------------------------------------------- letters are links
   Each letter is an SVG <a> (with a transparent hit box over its column). With WebGL the shader draws the
   letters, so the SVG is invisible but still there: opacity, not visibility, keeps hit-testing, the cursor,
   keyboard focus and screen readers working. Focus is drawn in dots by the shader. */

.logo .ln {
  cursor: pointer;
  /* touch: a press-and-hold is a gesture of its own (the curtain), not a link menu or a text selection */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* A link answers to the letter or the icon itself, and nothing round them (a tap near one used to open it: the whole column,
   with its empty corners, was the target). So no box is hit-testable: only the letter's shape while it shows the letter, and the
   mark's box while it shows the mark (hero.js sets .hit-lt / .hit-mk on each link as its shape changes, and both while the curtain
   has revealed the mark round the pointer). Keyboard focus is unchanged: the whole link still takes it. */
.logo .hit,
.logo .lt path,
.logo .mk-hit,
.logo .bf path {
  pointer-events: none;
}

.logo .ln.hit-lt .lt path,
.logo .ln.hit-mk .mk-hit {
  pointer-events: auto;
}

.logo .ln:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 2px;
}

.gl .logo .ln:focus-visible {
  outline: none;
}

/* With the live dot field, the pointer is drawn in dots (a small atom whose nucleus sits on the hotspot), so the
   system cursor is hidden: fine pointers only, and never in the no-WebGL or reduced-motion versions. */
@media (hover: hover) and (pointer: fine) {
  .gl.live body,
  .gl.live .logo .ln,
  .gl.live .theme {
    cursor: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo path, .scene { transition: none; }
}
