/* ╔══════════════════════════════════════════════════════════════════╗
   ║  R247 — Design tokens · macOS                                    ║
   ║  Shared by the app (styles.css) and the public pages (site.css). ║
   ║  System font, system colours, glass materials, accent colours.   ║
   ╚══════════════════════════════════════════════════════════════════╝ */

:root {
  /* SF Pro on Apple devices; Inter is the stand-in everywhere else
     (browsers only download it when the system font isn't there). */
  --font:         -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-rounded: ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Inter", system-ui, sans-serif;
  --font-mono:    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --spring:   cubic-bezier(0.34, 1.4, 0.64, 1);

  --r-window: 22px;
  --r-widget: 20px;
  --r-card:   14px;
  --r-ctl:    8px;

  /* Accent colours (System Settings → Appearance). l = light, d = dark */
  --accent-l: #0071E3; --accent-d: #0A84FF;
  --on-accent-l: #FFFFFF; --on-accent-d: #FFFFFF;

  /* System colours — tints for icons, dots, rings */
  --red:    #FF3B30; --orange: #FF9500; --yellow: #FFCC00; --green: #34C759;
  --mint:   #00C7BE; --teal:   #30B0C7; --blue:   #007AFF; --indigo: #5856D6;
  --purple: #AF52DE; --pink:   #FF2D55; --gray:   #8E8E93;
  /* Readable text versions of the same colours */
  --text-red: #D70015; --text-orange: #C25E00; --text-green: #1F8A3B; --text-blue: #0062CC;

  /* ── Light ── */
  --wallpaper:    url("/wallpaper-light.svg");
  --bg:           #F5F5F7;
  --bg-elevated:  #FFFFFF;
  --bg-sunken:    #ECECEE;
  --sidebar:      rgba(234, 237, 241, 0.66);
  --glass:        rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.84);
  --glass-edge:   rgba(255, 255, 255, 0.7);
  --label:        #1D1D1F;
  --label-2:      #6E6E73;
  --label-3:      #8E8E93;
  --label-4:      #C7C7CC;
  --separator:        rgba(60, 60, 67, 0.13);
  --separator-strong: rgba(60, 60, 67, 0.22);
  --fill:         rgba(120, 120, 128, 0.12);
  --fill-2:       rgba(120, 120, 128, 0.07);
  --hover:        rgba(0, 0, 0, 0.045);
  --selection:    rgba(0, 0, 0, 0.075);
  --control:      #FFFFFF;
  --scrim:        rgba(0, 0, 0, 0.18);
  --shadow-card:   0 0 0 0.5px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.05), 0 3px 10px rgba(0, 0, 0, 0.035);
  --shadow-raised: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.08), 0 14px 34px rgba(0, 0, 0, 0.07);
  --shadow-pop:    0 0 0 0.5px rgba(0, 0, 0, 0.14), 0 12px 32px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.06);
  --shadow-window: 0 0 0 0.5px rgba(0, 0, 0, 0.24), 0 28px 80px rgba(0, 0, 0, 0.28), 0 10px 24px rgba(0, 0, 0, 0.12);
  --shadow-ctl:    0 0 0 0.5px rgba(0, 0, 0, 0.14), 0 0.5px 1.5px rgba(0, 0, 0, 0.12);
  --chrome: #F5F5F7;

  --accent:    var(--accent-l);
  --on-accent: var(--on-accent-l);
  color-scheme: light;
}

/* ── Dark — follows the OS unless the reader picked a theme ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --wallpaper:    url("/wallpaper-dark.svg");
    --bg:           #1E1E1F;
    --bg-elevated:  #2A2A2C;
    --bg-sunken:    #171718;
    --sidebar:      rgba(40, 40, 44, 0.6);
    --glass:        rgba(44, 44, 48, 0.58);
    --glass-strong: rgba(40, 40, 43, 0.86);
    --glass-edge:   rgba(255, 255, 255, 0.1);
    --label:        #F5F5F7;
    --label-2:      #A1A1A6;
    --label-3:      #7C7C82;
    --label-4:      #48484A;
    --separator:        rgba(255, 255, 255, 0.09);
    --separator-strong: rgba(255, 255, 255, 0.16);
    --fill:         rgba(120, 120, 128, 0.26);
    --fill-2:       rgba(120, 120, 128, 0.16);
    --hover:        rgba(255, 255, 255, 0.06);
    --selection:    rgba(255, 255, 255, 0.1);
    --control:      rgba(255, 255, 255, 0.1);
    --scrim:        rgba(0, 0, 0, 0.42);
    --shadow-card:   0 0 0 0.5px rgba(255, 255, 255, 0.07), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-raised: 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-pop:    0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 14px 40px rgba(0, 0, 0, 0.55);
    --shadow-window: 0 0 0 0.5px rgba(255, 255, 255, 0.14), 0 30px 90px rgba(0, 0, 0, 0.6), 0 10px 26px rgba(0, 0, 0, 0.4);
    --shadow-ctl:    0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 0.5px 1.5px rgba(0, 0, 0, 0.4);
    --text-red: #FF6961; --text-orange: #FFB340; --text-green: #4CD964; --text-blue: #409CFF;
    --red: #FF453A; --orange: #FF9F0A; --yellow: #FFD60A; --green: #32D74B;
    --mint: #63E6E2; --teal: #40C8E0; --blue: #0A84FF; --indigo: #5E5CE6;
    --purple: #BF5AF2; --pink: #FF375F; --gray: #98989D;
    --chrome: #1E1E1F;
    --accent:    var(--accent-d);
    --on-accent: var(--on-accent-d);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --wallpaper:    url("/wallpaper-dark.svg");
  --bg:           #1E1E1F;
  --bg-elevated:  #2A2A2C;
  --bg-sunken:    #171718;
  --sidebar:      rgba(40, 40, 44, 0.6);
  --glass:        rgba(44, 44, 48, 0.58);
  --glass-strong: rgba(40, 40, 43, 0.86);
  --glass-edge:   rgba(255, 255, 255, 0.1);
  --label:        #F5F5F7;
  --label-2:      #A1A1A6;
  --label-3:      #7C7C82;
  --label-4:      #48484A;
  --separator:        rgba(255, 255, 255, 0.09);
  --separator-strong: rgba(255, 255, 255, 0.16);
  --fill:         rgba(120, 120, 128, 0.26);
  --fill-2:       rgba(120, 120, 128, 0.16);
  --hover:        rgba(255, 255, 255, 0.06);
  --selection:    rgba(255, 255, 255, 0.1);
  --control:      rgba(255, 255, 255, 0.1);
  --scrim:        rgba(0, 0, 0, 0.42);
  --shadow-card:   0 0 0 0.5px rgba(255, 255, 255, 0.07), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-raised: 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-pop:    0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 14px 40px rgba(0, 0, 0, 0.55);
  --shadow-window: 0 0 0 0.5px rgba(255, 255, 255, 0.14), 0 30px 90px rgba(0, 0, 0, 0.6), 0 10px 26px rgba(0, 0, 0, 0.4);
  --shadow-ctl:    0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 0.5px 1.5px rgba(0, 0, 0, 0.4);
  --text-red: #FF6961; --text-orange: #FFB340; --text-green: #4CD964; --text-blue: #409CFF;
  --red: #FF453A; --orange: #FF9F0A; --yellow: #FFD60A; --green: #32D74B;
  --mint: #63E6E2; --teal: #40C8E0; --blue: #0A84FF; --indigo: #5E5CE6;
  --purple: #BF5AF2; --pink: #FF375F; --gray: #98989D;
  --chrome: #1E1E1F;
  --accent:    var(--accent-d);
  --on-accent: var(--on-accent-d);
  color-scheme: dark;
}

/* ── Accent colours, picked in Settings → Appearance ── */
:root[data-accent="purple"]   { --accent-l: #8E44C9; --accent-d: #BF5AF2; }
:root[data-accent="pink"]     { --accent-l: #D6245E; --accent-d: #FF375F; }
:root[data-accent="red"]      { --accent-l: #D7261E; --accent-d: #FF453A; }
:root[data-accent="orange"]   { --accent-l: #C25E00; --accent-d: #FF9F0A; --on-accent-d: #1D1D1F; }
:root[data-accent="green"]    { --accent-l: #1F8A3B; --accent-d: #32D74B; --on-accent-d: #1D1D1F; }
:root[data-accent="graphite"] { --accent-l: #636366; --accent-d: #98989D; --on-accent-d: #1D1D1F; }

:root {
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --focus-ring:  0 0 0 3.5px color-mix(in srgb, var(--accent) 42%, transparent);
}

::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── App icon — R247's mark, a graphite squircle ── */
.app-icon {
  --size: 28px;
  width: var(--size); height: var(--size); flex-shrink: 0;
  display: inline-block;
  background: url("/favicon.svg") center / contain no-repeat;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.18));
}

/* ── Traffic lights ── */
.traffic { display: flex; align-items: center; gap: 8px; }
.traffic > * {
  position: relative;
  width: 12px; height: 12px; border-radius: 50%; padding: 0;
  border: 0; cursor: default;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.18);
}
.traffic .tl-close { background: #FF5F57; }
.traffic .tl-min   { background: #FEBC2E; }
.traffic .tl-zoom  { background: #28C840; }
.traffic.idle > * { background: var(--label-4); }
button.tl-close, button.tl-min, button.tl-zoom { cursor: pointer; }
.traffic button::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: center / 8px 8px no-repeat; opacity: 0; transition: opacity 0.12s;
}
.traffic:hover button::after { opacity: 1; }
.traffic .tl-close::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M1.8 1.8l4.4 4.4M6.2 1.8L1.8 6.2' stroke='%237A0C08' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.traffic .tl-min::after   { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M1.5 4h5' stroke='%23955A00' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.traffic .tl-zoom::after  { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M2 2.6v3.4h3.4zM6 5.4V2H2.6z' fill='%23075E14'/%3E%3C/svg%3E"); }

/* ── Light / dark switch (menu-bar style icon button) ── */
.theme-toggle {
  width: 32px; height: 32px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border-radius: 999px; border: 0;
  background: transparent; color: var(--label-2);
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}
.theme-toggle:hover { color: var(--label); background: var(--hover); }
.theme-toggle svg { width: 16px; height: 16px; }
/* whichever icon shows is the theme you'd switch to */
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}
