/* Tokens and ground. Light and dark, cool and neutral. */

:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: ui-serif, Georgia, "Times New Roman", serif; /* the corner "S" only */
  --font-mono: ui-monospace, Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-swift: cubic-bezier(0.32, 0.72, 0, 1);

  --menubar-h: 28px;
  --radius-window: 12px;

  /* Title-card gradients: the four pairs named in docs/14-keynote-app.md section
     4 — deep blue, slate, warm charcoal, muted plum. They are here rather than
     in one app's stylesheet because two apps set title cards from them: TV,
     where an entry has no wordmark, and Keynote, where a talk has no photograph.
     Cards drawn from the same four look like they came from the same hand.

     Every stop is dark enough for white type at 7:1 or better — the lightest of
     them, slate's top stop, measures 12.8:1 — so a card never has to dim its own
     background to stay legible. They do not change with the theme: a title card
     is a printed thing, the same in a light room as a dark one. */
  --card-blue: linear-gradient(150deg, #1b2b4d, #0d1526);
  --card-slate: linear-gradient(150deg, #2c333c, #14181e);
  --card-charcoal: linear-gradient(150deg, #34291f, #1a130d);
  --card-plum: linear-gradient(150deg, #35213c, #190f1e);
}

:root,
:root[data-theme="light"] {
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #ececee;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --hairline: rgba(0, 0, 0, 0.1);
  --hairline-strong: rgba(0, 0, 0, 0.16);
  --accent: #0071e3;
  --accent-selection: rgba(0, 113, 227, 0.14);
  --yellow: #e6b800;
  --up: #34c759;
  --down: #ff3b30;
  --neutral-pill: #8e8e93;

  --menubar-bg: rgba(255, 255, 255, 0.6);
  --dock-bg: rgba(255, 255, 255, 0.35);
  --dock-hairline: rgba(255, 255, 255, 0.5);
  --tooltip-bg: rgba(246, 246, 248, 0.9);
  --menu-bg: rgba(246, 246, 248, 0.84);
  --sidebar-bg: rgba(243, 243, 246, 0.8);

  --shadow-window:
    0 22px 70px rgba(0, 0, 0, 0.35),
    0 0 0 0.5px rgba(0, 0, 0, 0.15);
  --shadow-window-idle:
    0 10px 32px rgba(0, 0, 0, 0.2),
    0 0 0 0.5px rgba(0, 0, 0, 0.12);
  --tl-idle: #d6d6d6;

  --map-ocean: #dbe7f0;
  --map-land: #f3f4f2;
  --map-dot: #6e7a86;

  --wallpaper: var(--wp-light-override, url("../assets/wallpaper-light.svg"));
  --wall-fallback: #6a5fd0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #1e1e20;
    --surface-2: #28282a;
    --surface-3: #323234;
    --ink: #f5f5f7;
    --ink-2: #98989d;
    --hairline: rgba(255, 255, 255, 0.14);
    --hairline-strong: rgba(255, 255, 255, 0.22);
    --accent: #0a84ff;
    --accent-selection: rgba(10, 132, 255, 0.24);
    --yellow: #ffd60a;
    --up: #30d158;
    --down: #ff453a;
    --neutral-pill: #98989d;

    --menubar-bg: rgba(24, 24, 28, 0.4);
    --dock-bg: rgba(30, 30, 34, 0.3);
    --dock-hairline: rgba(255, 255, 255, 0.16);
    --tooltip-bg: rgba(44, 44, 48, 0.92);
    --menu-bg: rgba(40, 40, 44, 0.86);
    --sidebar-bg: rgba(38, 38, 42, 0.78);

    --shadow-window:
      0 22px 70px rgba(0, 0, 0, 0.6),
      0 0 0 0.5px rgba(255, 255, 255, 0.12);
    --shadow-window-idle:
      0 10px 32px rgba(0, 0, 0, 0.4),
      0 0 0 0.5px rgba(255, 255, 255, 0.09);
    --tl-idle: #4a4a4c;

    --map-ocean: #16202a;
    --map-land: #2b3138;
    --map-dot: #8d99a6;

    --wallpaper: var(--wp-dark-override, url("../assets/wallpaper-dark.svg"));
    --wall-fallback: #0e0e33;
  }
}

:root[data-theme="dark"] {
  --surface: #1e1e20;
  --surface-2: #28282a;
  --surface-3: #323234;
  --ink: #f5f5f7;
  --ink-2: #98989d;
  --hairline: rgba(255, 255, 255, 0.14);
  --hairline-strong: rgba(255, 255, 255, 0.22);
  --accent: #0a84ff;
  --accent-selection: rgba(10, 132, 255, 0.24);
  --yellow: #ffd60a;
  --up: #30d158;
  --down: #ff453a;
  --neutral-pill: #98989d;

  --menubar-bg: rgba(24, 24, 28, 0.4);
  --dock-bg: rgba(30, 30, 34, 0.3);
  --dock-hairline: rgba(255, 255, 255, 0.16);
  --tooltip-bg: rgba(44, 44, 48, 0.92);
  --menu-bg: rgba(40, 40, 44, 0.86);
  --sidebar-bg: rgba(38, 38, 42, 0.78);

  --shadow-window:
    0 22px 70px rgba(0, 0, 0, 0.6),
    0 0 0 0.5px rgba(255, 255, 255, 0.12);
  --shadow-window-idle:
    0 10px 32px rgba(0, 0, 0, 0.4),
    0 0 0 0.5px rgba(255, 255, 255, 0.09);
  --tl-idle: #4a4a4c;

  --map-ocean: #16202a;
  --map-land: #2b3138;
  --map-dot: #8d99a6;

  --wallpaper: var(--wp-dark-override, url("../assets/wallpaper-dark.svg"));
  --wall-fallback: #0e0e33;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font-ui);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--wall-fallback);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: default;
}

a { color: inherit; }

::selection { background: var(--accent-selection); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.wallpaper {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--wallpaper);
  background-size: cover;
  background-position: center;
}

/* The live sky paints over the still wallpaper, which stays as the fallback for
   a browser that gives us no canvas. */
.sky {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* One portrait, everywhere. Sized by whoever places it, always in whole
   multiples of the 48 pixel grid so the pixels stay hard rather than smeared. */
.pixel-avatar {
  display: block;
  flex: none;
  background-image: var(--avatar);
  background-repeat: no-repeat;
  background-size: calc(var(--frames, 4) * 100%) 100%;
  background-position: var(--frame, 0%) center;
  image-rendering: pixelated;
  border-radius: 50%;
  background-color: #11151f;
}

/* Only ever seen if the portrait file is missing. */
.avatar-monogram {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(160deg, #6f7480, #4a4e58);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Says whose sky this is. Bottom left, out of the dock's way and well under the
   mascot's feet; quiet enough to ignore and legible enough to answer the
   question a dark wallpaper at lunchtime raises. */
.sky-caption {
  position: fixed;
  left: 18px;
  bottom: 14px;
  z-index: 1;
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  opacity: 0.62;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  user-select: text;
  -webkit-user-select: text;
  pointer-events: none;
}

.sky-caption:empty { display: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms;
    transition-duration: 0.01ms;
  }
}
