/* Design tokens shared by the canvas (styles.css) and the case studies (case.css). */
:root {
  --paper: #ebe7dd;
  --sheet: #f4f1ea;
  --ink: #23221f;
  --ink-soft: #6b6760;
  --line-minor: rgba(110, 96, 78, 0.07);
  --line-major: rgba(176, 92, 60, 0.075);
  --frame-line: rgba(35, 34, 31, 0.16);
  --frame-edge: rgba(0, 0, 0, 0.12); /* drawn over images, so it only darkens their edge */
  --accent: #d9481c;
  --shadow: 0 1px 2px rgba(70, 58, 40, 0.06), 0 12px 32px -12px rgba(70, 58, 40, 0.18);
  --shadow-lift: 0 2px 4px rgba(70, 58, 40, 0.06), 0 28px 56px -16px rgba(70, 58, 40, 0.32); /* a tile lifted off the canvas */

  --grid-minor: 20px;
  --grid-major: 100px;
  --radius: 6px;
  --s: 1; /* layout scale, set by app.js on small screens */

  --font-sans: Geist, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* layers */
  --z-items: 1;
  --z-ui: 10;

  color-scheme: light;
}

/* Dark theme: follows the system unless the toggle has set data-theme on <html>.
   Keep the two blocks below in sync. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #1a1917;
    --sheet: #22211e;
    --ink: #ece8df;
    --ink-soft: #9a958b;
    --line-minor: rgba(236, 226, 208, 0.032);
    --line-major: rgba(232, 128, 92, 0.048);
    --frame-line: rgba(236, 232, 223, 0.16);
    --accent: #f0683c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.3), 0 28px 56px -16px rgba(0, 0, 0, 0.8);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1a1917;
  --sheet: #22211e;
  --ink: #ece8df;
  --ink-soft: #9a958b;
  --line-minor: rgba(236, 226, 208, 0.032);
  --line-major: rgba(232, 128, 92, 0.048);
  --frame-line: rgba(236, 232, 223, 0.16);
  --accent: #f0683c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.3), 0 28px 56px -16px rgba(0, 0, 0, 0.8);
}

/* Phones: the graph paper is fitted to the page instead of the other way round.
   The content keeps --page-pad either side, and the column between is split into
   an even number of squares of about 20 px (--grid-cells; --grid-half is half of
   them). So both edges of the column lie on a line, its middle does, and so does
   everything set on the grid inside it: tiles, slides, logo cells, cards.

   Across, a square is --grid-minor wide, a fraction of a pixel off 20. Down, it
   is --grid-y: the same rounded to a whole pixel, because the paper's rows are a
   repeated tile, and a tile that isn't whole pixels drifts off the content down
   a long page (the columns are drawn in one piece instead, see --paper-image).
   The squares are at most 2% off square.

   A major line every five, counted from the middle of the column, so they are
   the same either side (--grid-lead: how many squares in the first one falls).
   --paper-y (app.js, case.js) is where the rows start, down from the page's top.

   One line per count. app.js and case.js set the same values from the page's
   real width (--page-w: a classic scrollbar makes it less than 100vw). */
@media (max-width: 699px) {
  :root {
    --page-pad: 16px;
    --grid-cells: 14;
    --grid-half: 7;
    --grid-lead: 2;
    --grid-minor: calc((var(--page-w, 100vw) - 2 * var(--page-pad)) / var(--grid-cells));
    --grid-major: calc(var(--grid-minor) * 5);
    --grid-y: 20px;
    --paper-major-x: calc(var(--page-pad) + var(--grid-minor) * var(--grid-lead));
    --paper-image:
      repeating-linear-gradient(to right, var(--line-major) var(--paper-major-x), var(--line-major) calc(var(--paper-major-x) + 1px), transparent calc(var(--paper-major-x) + 1px), transparent calc(var(--paper-major-x) + var(--grid-major))),
      linear-gradient(to bottom, var(--line-major) 1px, transparent 1px),
      repeating-linear-gradient(to right, var(--line-minor) var(--page-pad), var(--line-minor) calc(var(--page-pad) + 1px), transparent calc(var(--page-pad) + 1px), transparent calc(var(--page-pad) + var(--grid-minor))),
      linear-gradient(to bottom, var(--line-minor) 1px, transparent 1px);
    --paper-size: 100% var(--grid-y), 100% calc(var(--grid-y) * 5), 100% var(--grid-y), 100% var(--grid-y);
    --paper-position: 0 var(--paper-y, 0px);
  }

  @supports (width: round(nearest, 10.4px, 1px)) {
    :root {
      --grid-y: round(nearest, var(--grid-minor), 1px);
    }
  }
}

@media (min-width: 332px) and (max-width: 699px) { :root { --grid-cells: 16; --grid-half: 8; --grid-lead: 3; } }
@media (min-width: 372px) and (max-width: 699px) { :root { --grid-cells: 18; --grid-half: 9; --grid-lead: 4; } }
@media (min-width: 412px) and (max-width: 699px) { :root { --grid-cells: 20; --grid-half: 10; --grid-lead: 0; } }
@media (min-width: 452px) and (max-width: 699px) { :root { --grid-cells: 22; --grid-half: 11; --grid-lead: 1; } }
@media (min-width: 492px) and (max-width: 699px) { :root { --grid-cells: 24; --grid-half: 12; --grid-lead: 2; } }
@media (min-width: 532px) and (max-width: 699px) { :root { --grid-cells: 26; --grid-half: 13; --grid-lead: 3; } }
@media (min-width: 572px) and (max-width: 699px) { :root { --grid-cells: 28; --grid-half: 14; --grid-lead: 4; } }
@media (min-width: 612px) and (max-width: 699px) { :root { --grid-cells: 30; --grid-half: 15; --grid-lead: 0; } }
@media (min-width: 652px) and (max-width: 699px) { :root { --grid-cells: 32; --grid-half: 16; --grid-lead: 1; } }
@media (min-width: 692px) and (max-width: 699px) { :root { --grid-cells: 34; --grid-half: 17; --grid-lead: 2; } }
