/*
 * SYSTEM 7
 * Classic Macintosh System 7-inspired: black/white/gray, 1-bit borders,
 * hard shadows, bitmap dithering, Chicago-flavored type.
 *
 * A fifth visual interpretation of the same workstation structure —
 * vladymir.info wearing the language of System 7, not a Mac emulator.
 */

:root[data-theme="system7"],
[data-theme="system7"] {
  color-scheme: light;

  /* Typography — Chicago/Geneva/Monaco approximation using bundled fonts. */
  --font-ui: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;        /* Geneva-ish */
  --font-copy: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;      /* neutral body */
  --font-mono: "IBM Plex Mono", Menlo, Monaco, Consolas, monospace;       /* Monaco-ish */
  --font-terminal: "IBM Plex Mono", Menlo, Monaco, Consolas, monospace;
  --font-display: "Chicago", "IBM Plex Sans Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif; /* Chicago */

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-strong: 600;

  --text-xxs: 10px;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 19px;
  --text-xl: 23px;

  --line-tight: 1.1;
  --line-ui: 1.2;
  --line-copy: 1.45;

  --tracking-ui: 0;
  --tracking-label: .04em;
  --tracking-display: .01em;

  /* Geometry — square, 1-bit, dense. */
  --space-1: 2px;
  --space-2: 4px;
  --space-3: 6px;
  --space-4: 8px;
  --space-5: 10px;
  --space-6: 12px;
  --space-7: 16px;
  --space-8: 20px;

  --radius-window: 0;
  --radius-control: 0;
  --border-width: 1px;

  --titlebar-height: 25px;
  --titlebar-button-size: 17px;
  --menubar-height: 25px;
  --front-panel-height: 68px;
  --statusbar-height: 22px;
  --dockapp-size: 104px;
  --window-gap: 10px;
  --dockapp-gap: 8px;
  --scrollbar-size: 15px;
  --meter-height: 6px;

  /* Palette — near-monochrome. */
  --s7-white: #ffffff;
  --s7-black: #000000;
  --s7-gray-0: #fbfbfb;
  --s7-gray-1: #ededed;
  --s7-gray-2: #d9d9d9;
  --s7-gray-3: #b3b3b3;
  --s7-gray-4: #8c8c8c;
  --s7-gray-5: #666666;
  --s7-gray-6: #333333;

  --desktop-bg: #9c9c9c;
  --desktop-bg-alt: #8f8f8f;

  --surface-window: var(--s7-white);
  --surface-window-alt: var(--s7-gray-0);
  --surface-raised: var(--s7-gray-1);
  --surface-sunken: var(--s7-white);
  --surface-input: var(--s7-white);
  --surface-menubar: var(--s7-white);
  --surface-titlebar: var(--s7-gray-1);
  --surface-titlebar-inactive: var(--s7-gray-2);
  --surface-statusbar: var(--s7-gray-1);
  --surface-dockapp: var(--s7-white);
  --surface-terminal: var(--s7-white);
  --surface-selection: var(--s7-black);

  --text-primary: var(--s7-black);
  --text-secondary: var(--s7-gray-6);
  --text-muted: var(--s7-gray-5);
  --text-disabled: var(--s7-gray-3);
  --text-titlebar: var(--s7-black);
  --text-titlebar-inactive: var(--s7-gray-5);
  --text-menubar: var(--s7-black);
  --text-statusbar: var(--s7-black);
  --text-terminal: var(--s7-black);
  --text-terminal-dim: var(--s7-gray-5);

  --accent-primary: var(--s7-black);
  --accent-secondary: var(--s7-gray-5);
  --accent-tertiary: var(--s7-gray-4);
  --accent-warning: var(--s7-gray-6);
  --accent-danger: var(--s7-black);
  --accent-ok: var(--s7-black);

  --link: var(--s7-black);
  --link-hover: var(--s7-gray-6);
  --selection-bg: var(--s7-black);
  --selection-fg: var(--s7-white);
  --focus-color: var(--s7-black);

  --border-outer: var(--s7-black);
  --border-inner: var(--s7-gray-4);
  --border-muted: var(--s7-gray-3);
  --bevel-highlight: var(--s7-white);
  --bevel-light: var(--s7-gray-1);
  --bevel-dark: var(--s7-gray-4);
  --bevel-shadow: var(--s7-black);
  --separator: var(--s7-gray-3);
  --window-outline: var(--s7-black);
  --titlebar-rule: 1px solid var(--s7-gray-4);

  --shadow-window: 2px 2px 0 var(--s7-black);
  --shadow-raised:
    inset 1px 1px 0 var(--bevel-highlight),
    inset -1px -1px 0 var(--bevel-shadow),
    inset 2px 2px 0 var(--bevel-light),
    inset -2px -2px 0 var(--bevel-dark);
  --shadow-sunken:
    inset 1px 1px 0 var(--bevel-shadow),
    inset -1px -1px 0 var(--bevel-highlight),
    inset 2px 2px 0 var(--bevel-dark),
    inset -2px -2px 0 var(--bevel-light);
  --shadow-focus: inset 0 0 0 1px var(--focus-color);

  --glow-text: none;
  --glow-accent: none;
  --glow-terminal: none;

  --meter-track: var(--s7-gray-2);
  --meter-fill: var(--s7-black);
  --meter-fill-alt: var(--s7-gray-5);
  --meter-fill-warn: var(--s7-gray-4);

  --graph-grid: var(--s7-gray-3);
  --graph-line: var(--s7-black);
  --graph-line-alt: var(--s7-gray-5);
  --graph-baseline: var(--s7-gray-4);

  --led-off: var(--s7-gray-3);
  --led-on: var(--s7-black);
  --led-warn: var(--s7-gray-5);

  --dock-label: var(--s7-gray-5);
  --dock-value: var(--s7-black);

  --terminal-prompt: var(--s7-black);
  --terminal-user: var(--s7-gray-6);
  --terminal-path: var(--s7-gray-5);
  --terminal-command: var(--s7-black);
  --terminal-cursor: var(--s7-black);
  --terminal-error: var(--s7-black);
  --terminal-warning: var(--s7-gray-5);

  --workspace-active-bg: var(--s7-black);
  --workspace-active-fg: var(--s7-white);
  --workspace-inactive-bg: var(--s7-white);
  --workspace-inactive-fg: var(--s7-black);
  --workspace-border: var(--s7-black);

  /* Optical treatment — none; the "texture" is the dither pattern below. */
  --scanline-color: var(--s7-black);
  --scanline-opacity: 0;
  --scanline-size: 0px;
  --noise-opacity: 0;
  --vignette-opacity: 0;
  --phosphor-blur: 0px;

  --image-filter: none;
  --icon-opacity: 1;
  --avatar-bg: var(--s7-white);
  --avatar-filter: none;
  --avatar-opacity: 1;
}

/* Desktop: light gray with a subtle 1-bit checkerboard dither. */
[data-theme="system7"] body {
  background-color: var(--desktop-bg);
  background-image:
    linear-gradient(45deg, rgb(0 0 0 / 6%) 25%, transparent 25%, transparent 75%, rgb(0 0 0 / 6%) 75%),
    linear-gradient(45deg, rgb(0 0 0 / 6%) 25%, transparent 25%, transparent 75%, rgb(0 0 0 / 6%) 75%);
  background-size: 4px 4px;
  background-position: 0 0, 2px 2px;
}

/* Menubar: flat white with a single black rule and the same pinstripes
   as the window titlebars. */
[data-theme="system7"] .menubar {
  border: 0;
  border-bottom: 1px solid var(--s7-black);
  box-shadow: none;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 1px,
    rgb(0 0 0 / 12%) 1px 2px
  );
}

[data-theme="system7"] .menubar__brand {
  font-family: var(--font-display);
  font-weight: var(--weight-strong);
  letter-spacing: 0;
}

/* Windows: keep the 1px black border, drop the bevel, keep the hard shadow. */
[data-theme="system7"] .window {
  box-shadow: var(--shadow-window);
}

/* Titlebar: horizontal pinstripes + Chicago-flavored type. */
[data-theme="system7"] .window__titlebar {
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  letter-spacing: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 1px,
    rgb(0 0 0 / 12%) 1px 2px
  );
}

/* Titlebar glyph: a small 1-bit square instead of the braille mark. */
[data-theme="system7"] .window__titlebar::before {
  content: "";
  width: 9px;
  height: 9px;
  border: 1px solid var(--s7-black);
  background: var(--s7-white);
  box-shadow: inset 1px 1px 0 var(--s7-white), inset -1px -1px 0 var(--s7-gray-4);
}

/* Menu items and launchers invert to black when hovered. */
[data-theme="system7"] .menubar__nav a:hover,
[data-theme="system7"] .front-panel__launchers a:hover {
  background: var(--s7-black);
  color: var(--s7-white);
}

/* Content links: dotted focus; hard inversion on hover. */
[data-theme="system7"] .notes-editor__doc a:focus-visible,
[data-theme="system7"] .compact-writing a:focus-visible {
  outline: 1px dotted var(--s7-black);
  outline-offset: 1px;
}
[data-theme="system7"] .notes-editor__doc a:hover,
[data-theme="system7"] .compact-writing a:hover {
  background: var(--s7-black);
  color: var(--s7-white);
}

/* Code blocks: classic white field with a black border. */
[data-theme="system7"] pre code[class^="language-"] {
  display: block;
  background: var(--s7-white);
  color: var(--s7-black);
  border: 1px solid var(--s7-black);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
}

/* Blockquotes: a simple classic pull-note. */
[data-theme="system7"] .notes-editor__doc blockquote {
  margin-inline: 0;
  padding: var(--space-2) var(--space-4);
  border-left: 3px solid var(--s7-black);
  background: var(--s7-gray-1);
}

/* Dockapps: a discreet dot grid over white, like classic bitmap paper. */
[data-theme="system7"] .dockapp {
  background-image: radial-gradient(var(--s7-gray-2) 0.75px, transparent 0.75px);
  background-size: 12px 12px;
}

/* Selection: hard black-on-white inversion. */
[data-theme="system7"] ::selection {
  background: var(--s7-black);
  color: var(--s7-white);
}
