/* Twinlight · the observatory · tokens
   The whole system as custom properties. One property drives the light:
   --tw-balance, 0 = the sun's light, 0.5 = both (dusk, the default), 1 = the moon's light.
   Every text/ground pair below holds 4.5:1 or better at every balance from 0 to 1
   (checked by mixing in oklab at steps of 0.1, as color-mix does; the lowest pair is 5.7:1).
   Fonts: no downloads. The reading face is an old-style serif already on most machines
   (Iowan Old Style on Apple, Palatino Linotype on Windows, URW Palladio on Linux), with Georgia last. */

@property --tw-balance {
  syntax: "<number>";
  inherits: true;
  initial-value: 0.5;
}

:root {
  --tw-balance: 0.5;

  /* ---------- The two lights (fixed; never gendered, never pink or blue-for-anyone) ---------- */
  /* The sun, as on his 2012 cover: white-gold core, gold rays, bronze. */
  --tw-sun-core:   #fbf1d3;
  --tw-sun-ray:    #dcaa4a;
  --tw-sun-bronze: #9c6b25;
  /* The moon: blue-white core, ice rings, steel. Its light is the sun's, returned. */
  --tw-moon-core:  #eef4fb;
  --tw-moon-ring:  #a9c5e4;
  --tw-moon-steel: #5f7d9e;

  /* The blue of the court: the one blue place. Neither light's colour; what appears between them. */
  --tw-court:      #11275a;
  --tw-court-deep: #0a1a40;
  --tw-court-lit:  #1f3f86;

  /* ---------- Grounds and inks at the two ends (the balance mixes between them) ---------- */
  /* Night plate: the dark of the sky and the water. */
  --tw-night-solar:        #17120e;  /* umber-black, the last of the sun in it */
  --tw-night-lunar:        #0a0f1c;  /* blue-black */
  --tw-night-ink-solar:    #f2e7cf;
  --tw-night-ink-lunar:    #e2eaf4;
  --tw-night-muted-solar:  #c7b08a;
  --tw-night-muted-lunar:  #9fb2cb;
  /* The leaf: the paper a page is read on. Warmer under the sun, cooler under the moon, always light. */
  --tw-leaf-solar:         #f3ead8;
  --tw-leaf-lunar:         #e5eaf0;
  --tw-leaf-ink-solar:     #1e1a15;
  --tw-leaf-ink-lunar:     #141a24;
  --tw-leaf-muted-solar:   #5c5143;
  --tw-leaf-muted-lunar:   #46525f;
  /* The leaf read by lamplight (prefers-color-scheme: dark). */
  --tw-lamp-solar:         #1b1612;
  --tw-lamp-lunar:         #0f1420;
  --tw-lamp-ink-solar:     #ece2cc;
  --tw-lamp-ink-lunar:     #dde5ef;
  --tw-lamp-muted-solar:   #bba887;
  --tw-lamp-muted-lunar:   #98abc2;

  /* Accent inks, used for small labels and marks that belong to one light. */
  --tw-solar-ink-on-dark:  #e4b862;
  --tw-lunar-ink-on-dark:  #a9c5e4;
  --tw-solar-ink-on-leaf:  #7a5212;
  --tw-lunar-ink-on-leaf:  #2c5277;
  --tw-solar-ink-on-court: #efc874;
  --tw-lunar-ink-on-court: #c6dbf2;
  --tw-court-ink:          #eef2fa;
  --tw-court-muted:        #b7c6e3;

  /* ---------- Type ---------- */
  --tw-face-text: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, Georgia, serif;
  /* Labels are the same face in spaced capitals, as engraved on an instrument's limb. */
  --tw-face-label: var(--tw-face-text);
  --tw-numerals: oldstyle-nums proportional-nums;
  --tw-numerals-table: lining-nums tabular-nums;

  /* Scale: ratio 1.25 around a reading size that grows a little with the window. */
  --tw-size-text: clamp(1.0625rem, 0.96rem + 0.42vw, 1.25rem);
  --tw-step--2: calc(var(--tw-size-text) * 0.68);   /* limb labels */
  --tw-step--1: calc(var(--tw-size-text) * 0.84);   /* whose words, captions, notes */
  --tw-step-0:  var(--tw-size-text);
  --tw-step-1:  calc(var(--tw-size-text) * 1.25);
  --tw-step-2:  calc(var(--tw-size-text) * 1.5625);
  --tw-step-3:  calc(var(--tw-size-text) * 1.953);
  --tw-step-4:  clamp(2rem, 1.3rem + 2.6vw, 3.2rem); /* a page's title */

  --tw-leading-text: 1.62;
  --tw-leading-tight: 1.18;
  --tw-measure: 34em;          /* about 66 characters of the reading face */
  --tw-measure-narrow: 26em;
  --tw-label-track: 0.14em;    /* letter-spacing for capitals */

  /* ---------- Space (a 4 px module) ---------- */
  --tw-space-1: 0.25rem;
  --tw-space-2: 0.5rem;
  --tw-space-3: 0.75rem;
  --tw-space-4: 1rem;
  --tw-space-5: 1.5rem;
  --tw-space-6: 2rem;
  --tw-space-7: 3rem;
  --tw-space-8: 4.5rem;
  --tw-gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);

  /* ---------- Rules and ornaments ---------- */
  --tw-hair: 1px;
  --tw-rule-gap: 3px;          /* the gap in a double rule */
  /* A graduated limb: a tick every 1/72 of a length, longer every sixth. Use as a background. */
  --tw-graduation:
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px calc(100% / 12)),
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px calc(100% / 72));
  --tw-graduation-size: 100% 7px, 100% 3px;
  /* The two emblems, drawn here, used as masks so they take the colour of their light. */
  --tw-glyph-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-12 -12 24 24'%3E%3Ccircle r='3.2'/%3E%3Cg id='r'%3E%3Cpath d='M0-4.6 0.9-6.2 0-11.6-0.9-6.2Z'/%3E%3Cpath d='M0-4.6 0.9-6.2 0-11.6-0.9-6.2Z' transform='rotate(45)'/%3E%3Cpath d='M0-4.6 0.9-6.2 0-11.6-0.9-6.2Z' transform='rotate(90)'/%3E%3Cpath d='M0-4.6 0.9-6.2 0-11.6-0.9-6.2Z' transform='rotate(135)'/%3E%3C/g%3E%3Cuse href='%23r' transform='rotate(180)'/%3E%3Cg transform='rotate(22.5)'%3E%3Cpath d='M0-5 0.6-6 0-8.6-0.6-6Z'/%3E%3Cpath d='M0-5 0.6-6 0-8.6-0.6-6Z' transform='rotate(90)'/%3E%3Cpath d='M0-5 0.6-6 0-8.6-0.6-6Z' transform='rotate(180)'/%3E%3Cpath d='M0-5 0.6-6 0-8.6-0.6-6Z' transform='rotate(270)'/%3E%3C/g%3E%3Cg transform='rotate(67.5)'%3E%3Cpath d='M0-5 0.6-6 0-8.6-0.6-6Z'/%3E%3Cpath d='M0-5 0.6-6 0-8.6-0.6-6Z' transform='rotate(90)'/%3E%3Cpath d='M0-5 0.6-6 0-8.6-0.6-6Z' transform='rotate(180)'/%3E%3Cpath d='M0-5 0.6-6 0-8.6-0.6-6Z' transform='rotate(270)'/%3E%3C/g%3E%3C/svg%3E");
  --tw-glyph-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-12 -12 24 24' fill='none' stroke='%23000'%3E%3Ccircle r='3.2' fill='%23000' stroke='none'/%3E%3Ccircle r='5.4' stroke-width='1.1'/%3E%3Ccircle r='7.6' stroke-width='0.9'/%3E%3Ccircle r='9.6' stroke-width='0.7'/%3E%3Ccircle r='11.4' stroke-width='0.5'/%3E%3C/svg%3E");

  /* ---------- Focus and motion ---------- */
  --tw-focus-width: 2px;
  --tw-focus-offset: 3px;
  --tw-ease: cubic-bezier(0.3, 0, 0.2, 1);
  --tw-dur-quick: 180ms;
  --tw-dur-light: 1600ms;      /* the time the light takes to settle when a page sets it */
}

/* ---------- Derived tokens: recomputed wherever a balance is set ----------
   Put class="tw-light" on any element that sets its own --tw-balance (a family's station, a page). */
:root, .tw-light {
  --tw-s: calc((1 - var(--tw-balance)) * 100%);   /* how much of the sun */

  --tw-night:       color-mix(in oklab, var(--tw-night-solar) var(--tw-s), var(--tw-night-lunar));
  --tw-night-ink:   color-mix(in oklab, var(--tw-night-ink-solar) var(--tw-s), var(--tw-night-ink-lunar));
  --tw-night-muted: color-mix(in oklab, var(--tw-night-muted-solar) var(--tw-s), var(--tw-night-muted-lunar));

  --tw-leaf:        color-mix(in oklab, var(--tw-leaf-solar) var(--tw-s), var(--tw-leaf-lunar));
  --tw-leaf-ink:    color-mix(in oklab, var(--tw-leaf-ink-solar) var(--tw-s), var(--tw-leaf-ink-lunar));
  --tw-leaf-muted:  color-mix(in oklab, var(--tw-leaf-muted-solar) var(--tw-s), var(--tw-leaf-muted-lunar));

  --tw-lamp:        color-mix(in oklab, var(--tw-lamp-solar) var(--tw-s), var(--tw-lamp-lunar));
  --tw-lamp-ink:    color-mix(in oklab, var(--tw-lamp-ink-solar) var(--tw-s), var(--tw-lamp-ink-lunar));
  --tw-lamp-muted:  color-mix(in oklab, var(--tw-lamp-muted-solar) var(--tw-s), var(--tw-lamp-muted-lunar));

  /* The light itself, as a single colour: a station's mark, the index on the band. */
  --tw-light-mark:  color-mix(in oklab, var(--tw-sun-ray) var(--tw-s), var(--tw-moon-ring));

  /* The sky at the horizon and overhead. At dusk: gold low on the sun's side, the earth's blue
     shadow with its band of rose low on the moon's side, deep blue-black overhead. */
  --tw-sky-zenith:   color-mix(in oklab, #1a2340 var(--tw-s), #070b18);
  --tw-sky-sun-low:  color-mix(in oklab, #b0742f var(--tw-s), #3a2a2a);
  --tw-sky-sun-mid:  color-mix(in oklab, #5b4a52 var(--tw-s), #1a1c30);
  --tw-sky-moon-low: color-mix(in oklab, #6f6a86 var(--tw-s), #2a3550);
  --tw-sky-rose:     color-mix(in oklab, #8a6670 var(--tw-s), #3c3a52);
  --tw-water:        color-mix(in oklab, #120f10 var(--tw-s), #070b15);
}

/* ---------- Surfaces: what each ground means for its inks ---------- */
.tw-surface-night {
  --tw-ground: var(--tw-night);
  --tw-ink: var(--tw-night-ink);
  --tw-muted: var(--tw-night-muted);
  --tw-solar-ink: var(--tw-solar-ink-on-dark);
  --tw-lunar-ink: var(--tw-lunar-ink-on-dark);
  --tw-rule: color-mix(in oklab, var(--tw-night-muted) 45%, transparent);
  --tw-focus: #ffd98a;
}
.tw-surface-court {
  --tw-ground: var(--tw-court);
  --tw-ink: var(--tw-court-ink);
  --tw-muted: var(--tw-court-muted);
  --tw-solar-ink: var(--tw-solar-ink-on-court);
  --tw-lunar-ink: var(--tw-lunar-ink-on-court);
  --tw-rule: color-mix(in oklab, var(--tw-court-muted) 40%, transparent);
  --tw-focus: #ffd98a;
}
.tw-surface-leaf {
  --tw-ground: var(--tw-leaf);
  --tw-ink: var(--tw-leaf-ink);
  --tw-muted: var(--tw-leaf-muted);
  --tw-solar-ink: var(--tw-solar-ink-on-leaf);
  --tw-lunar-ink: var(--tw-lunar-ink-on-leaf);
  --tw-rule: color-mix(in oklab, var(--tw-leaf-muted) 45%, transparent);
  --tw-focus: #1c4a8a;
}
@media (prefers-color-scheme: dark) {
  .tw-surface-leaf {
    --tw-ground: var(--tw-lamp);
    --tw-ink: var(--tw-lamp-ink);
    --tw-muted: var(--tw-lamp-muted);
    --tw-solar-ink: #e0b25c;
    --tw-lunar-ink: #a3c0df;
    --tw-rule: color-mix(in oklab, var(--tw-lamp-muted) 40%, transparent);
    --tw-focus: #ffd98a;
  }
}

/* Older browsers without color-mix: hold the light at dusk, with the same inks. */
@supports not (color: color-mix(in oklab, red 50%, blue)) {
  :root, .tw-light {
    --tw-night: #110f15; --tw-night-ink: #eae8e2; --tw-night-muted: #b3b1ab;
    --tw-leaf: #ece9e4; --tw-leaf-ink: #19191c; --tw-leaf-muted: #514f50;
    --tw-lamp: #15141a; --tw-lamp-ink: #e4e3de; --tw-lamp-muted: #aaa9a4;
    --tw-light-mark: #c2b591;
    --tw-sky-zenith: #10162b; --tw-sky-sun-low: #73513a; --tw-sky-sun-mid: #3a3441;
    --tw-sky-moon-low: #4c4f6b; --tw-sky-rose: #635061; --tw-water: #0c0d13;
  }
  .tw-surface-night, .tw-surface-court, .tw-surface-leaf { --tw-rule: rgba(160, 160, 170, 0.45); }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --tw-dur-quick: 0ms;
    --tw-dur-light: 0ms;
  }
}
