/* ipheion — the library in the evening.
   The garden's own page after dark, laid over app.css (themes.py says when).
   Walnut panelling and shelves of leather-bound books, lit by a candle and a
   banker's lamp; the paper becomes the green leather of a writing desk, tooled
   in gilt; your words arrive on claret letter-paper, the agent's beside a
   quill. The ribbon is a velvet bookmark, the buttons brass plates, and the
   garden's lilac deepens to Sappho's violets. Light falls warm from the front
   and above, so shadows go down and are near black.

   Only colour, light and ornament change here: nothing is a different size
   from the garden, so nothing moves when the room changes, and the scroll and
   layout gates measured in the garden hold here. The protanomaly rule holds:
   no meaning rests on red against green (the claret letters and the green desk
   differ in lightness as well as hue). */

:root {
  color-scheme: dark;
  --ink: #e8dcc4;
  --ink-soft: #b3a185;
  --ink-strong: #fbf1dc;
  --paper: #13201a;
  --paper-deep: #0f1914;
  --blush-deep: #b8506a;
  --rose: #c4566f;
  --rose-ink: #e7a3b0;
  --wisteria: #b39ae6;
  --wisteria-deep: #cdb8f5;
  --leaf: #7f9c6c;
  --leaf-ink: #bcd29f;
  --gold: #c9a04a;
  --gold-light: #7d6029;
  --gold-deep: #e6c477;
  --walnut: #23160e;
  --night: #120b07;
  --fade: rgba(22, 14, 10, .95);
  /* Leather grain, and the walnut wainscot (tools/ornaments.py). */
  --noise: url("library/grain.svg");
  --panels: url("library/panels.svg");
}

html { scrollbar-color: #5a4322 var(--night); }
body { background: var(--night); color: var(--ink); }
/* The room: panelling, a chandelier's warm pool overhead, a candle low on
   the left and the lamp low on the right, the corners lost in shadow. */
body::before {
  background:
    radial-gradient(75% 50% at 50% -8%, rgba(255, 186, 110, .17), rgba(255, 186, 110, 0) 70%),
    radial-gradient(38% 42% at 4% 100%, rgba(255, 150, 70, .16), rgba(255, 150, 70, 0) 70%),
    radial-gradient(38% 42% at 96% 100%, rgba(255, 210, 140, .11), rgba(255, 210, 140, 0) 70%),
    radial-gradient(140% 100% at 50% 40%, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, .55) 100%),
    var(--panels),
    linear-gradient(180deg, #24170f 0%, #1b110b 50%, #140c08 100%);
}

a { color: var(--rose-ink); }
a:hover { color: var(--wisteria-deep); }
::selection { background: rgba(168, 52, 79, .6); color: #fff4e2; }

/* --- the shelves along the top; a candle and a lamp in the corners --- */
.arbor {
  height: 260px;
  background: url("library/shelves.svg") center top / auto 260px repeat-x;
  -webkit-mask-image: linear-gradient(180deg, #000 40%, rgba(0, 0, 0, .3) 64%, transparent 88%);
  mask-image: linear-gradient(180deg, #000 40%, rgba(0, 0, 0, .3) 64%, transparent 88%);
}
/* Warm light over the spines. */
.arbor::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 90% at 50% 0%, rgba(255, 190, 110, .14), rgba(255, 190, 110, 0) 70%);
}
@media (max-width: 640px) { .arbor { height: 160px; background-size: auto 160px; opacity: .9; } }
.roses.l { background-image: url("library/candle.svg"); }
.roses.r { background-image: url("library/lamp.svg"); }
/* The candle breathes: one layer, opacity and scale only. */
.roses.l::after {
  content: "";
  position: absolute;
  left: -16px;
  bottom: 76px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 196, 120, .34), rgba(255, 150, 70, .1) 55%, rgba(255, 150, 70, 0));
  will-change: opacity, transform;
  animation: flicker 5.3s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { opacity: .85; transform: scale(1); }
  11% { opacity: 1; transform: scale(1.04); }
  19% { opacity: .78; transform: scale(.97); }
  34% { opacity: .95; transform: scale(1.02); }
  52% { opacity: .82; transform: scale(.99); }
  61% { opacity: 1; transform: scale(1.05); }
  78% { opacity: .88; transform: scale(1); }
}

/* --- dust in the lamplight, where the garden has petals --- */
.petals i,
.petals i:nth-child(n) {
  top: auto;
  bottom: -2vh;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffe2b0;
  box-shadow: 0 0 6px 2px rgba(255, 190, 110, .45);
  opacity: 0;
  animation-name: motes;
  animation-timing-function: ease-in-out;
}
.petals i:nth-child(2), .petals i:nth-child(5) { width: 2px; height: 2px; }
.petals i:nth-child(4) { background: #e9dcff; box-shadow: 0 0 6px 2px rgba(179, 154, 230, .4); }
@keyframes motes {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  12%  { opacity: .75; }
  50%  { transform: translate3d(calc(var(--drift) * -.5), -52vh, 0); opacity: .45; }
  80%  { opacity: .6; }
  100% { transform: translate3d(calc(var(--drift) * .4), -104vh, 0); opacity: 0; }
}

/* --- masthead --- */
.wordmark { color: #f3dfb0; background: radial-gradient(closest-side, rgba(18, 11, 7, .94) 55%, rgba(18, 11, 7, .65) 78%, rgba(18, 11, 7, 0)); }
.wordmark span { text-shadow: 0 1px 0 #000, 0 0 16px rgba(255, 176, 90, .55), 0 0 2px rgba(255, 214, 150, .4); }
.wordmark .mark { background-image: url("library/starflower.svg"); filter: drop-shadow(0 0 5px rgba(179, 154, 230, .55)); }
.wordmark .flourish { background-image: url("library/flourish.svg"); }
.wordmark:hover { color: var(--gold-deep); }
.icon-btn {
  color: #e3bf6e;
  background: radial-gradient(circle at 50% 30%, #3e2c1e, #1b120c 75%);
  border-color: #8a6a2e;
  box-shadow: 0 0 0 2px var(--night), 0 0 0 3px rgba(201, 160, 74, .6), 0 4px 10px -3px rgba(0, 0, 0, .8);
}
.icon-btn:hover { color: #f6dfa0; }
/* The almanac's book: parchment pages in the lamplight. */
.almanac-toggle svg path:first-child { fill: #d6c49c; }
.pansy svg { filter: drop-shadow(0 0 4px rgba(255, 176, 90, .25)) drop-shadow(0 1px 1px rgba(0, 0, 0, .6)); }
.pansy .petal { stroke: rgba(0, 0, 0, .55); }
.pansy .petal:nth-of-type(3n+1) { fill: #8f70cc; }
.pansy .petal:nth-of-type(3n+2) { fill: #b8506a; }
.pansy .petal:nth-of-type(3n)   { fill: #d6a24a; }
.pansy .petal.spent { fill: #3a2c24; opacity: .75; }
.pansy .heart { fill: #f2c94c; stroke: #8a6a2e; }

/* --- the almanac: an index of earlier evenings --- */
.almanac {
  background: var(--noise), linear-gradient(180deg, #24180f, #170f0a);
  border-right-color: #5a4322;
  box-shadow: 10px 0 34px -12px rgba(0, 0, 0, .85);
}
body.almanac-open::after { background: rgba(6, 3, 2, .58); }
.almanac li a:hover { background: rgba(201, 160, 74, .09); }
.almanac li a[aria-current="page"] { background: linear-gradient(90deg, rgba(122, 30, 50, .6), rgba(122, 30, 50, 0)); }
/* Flowers pressed between the pages long ago: darker, browner. */
.bloom[class] { background: #c99a45; box-shadow: 0 -6px 0 1px var(--b), 0 6px 0 1px var(--b), -6px 0 0 1px var(--b), 6px 0 0 1px var(--b); }
.b0 { --b: #6f58a3; } .b1 { --b: #8e3a52; } .b3 { --b: #4e6b45; } .b4 { --b: #8c5846; }
.bloom.b2[class] { --b: #a8813a; background: #7a3a18; }
@media (min-width: 1180px) {
  .almanac { border-color: #5a4322; box-shadow: 0 0 0 4px var(--walnut), 0 0 0 5px rgba(201, 160, 74, .45), 0 16px 34px -14px rgba(0, 0, 0, .9); }
}

/* --- the ribbon: a velvet bookmark, its edges stitched in gold thread --- */
.ribbon .label {
  color: #f7e7c6;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .7), 0 0 10px rgba(255, 190, 110, .25);
  background:
    linear-gradient(180deg, rgba(255, 220, 220, .12), rgba(255, 220, 220, 0) 40%),
    linear-gradient(180deg, #933144 0%, #6c1c2d 55%, #551422 100%);
  border-top-color: #c9a04a;
  border-bottom-color: #8a6a2e;
  box-shadow: inset 0 3px 0 -2px rgba(236, 208, 138, .55), inset 0 -3px 0 -2px rgba(236, 208, 138, .4), 0 6px 12px -4px rgba(0, 0, 0, .8);
}
.ribbon .label::before, .ribbon .label::after { background: linear-gradient(180deg, #74222f, #420f1b); }
.chat-page .ribbon::before { background: linear-gradient(180deg, var(--fade) 0, var(--fade) 58%, rgba(22, 14, 10, 0)); }

/* --- the desk: green leather, tooled in gilt, in a walnut frame --- */
.paper {
  background:
    var(--noise),
    radial-gradient(90% 55% at 50% 0%, rgba(255, 196, 120, .1), rgba(255, 196, 120, 0) 70%),
    radial-gradient(130% 100% at 50% 50%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, .35) 100%),
    linear-gradient(180deg, #17261d, var(--paper-deep));
  border-color: #5a4322;
  box-shadow:
    0 0 0 5px var(--walnut),
    0 0 0 6px #a5803a,
    0 0 0 8px #1a110b,
    0 0 0 9px rgba(201, 160, 74, .35),
    0 30px 60px -24px rgba(0, 0, 0, .9),
    0 4px 12px rgba(0, 0, 0, .45);
  /* The tooled line, a finger's width in from the edge. */
  outline: 1px solid rgba(201, 160, 74, .3);
  outline-offset: -9px;
}
.corner { background-image: url("library/corner.svg"); }
.garland { background-image: url("library/garland.svg"); }

.seal { background-image: url("library/seal.svg"); filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .65)); }
/* The seeds become reading-room call slips. */
.seed {
  color: #e6c98a;
  background: var(--noise), linear-gradient(180deg, #3a2b1d, #2a1e14);
  border-color: #6b5326;
  outline-color: rgba(201, 160, 74, .4);
  box-shadow: 0 2px 0 #0f0a07, 0 8px 14px -8px rgba(0, 0, 0, .85);
}
.seed:hover { box-shadow: 0 3px 0 #0f0a07, 0 12px 18px -8px rgba(0, 0, 0, .85); }

/* --- messages: yours a letter on claret paper, its corner turned down --- */
.msg.human {
  color: #f6e8d8;
  background: var(--noise), linear-gradient(170deg, #521c28, #3b121c);
  border-color: #7a3242;
  box-shadow: inset 0 1px 0 rgba(255, 200, 200, .08), 0 10px 20px -10px rgba(0, 0, 0, .85);
}
.msg.human::after {
  background: linear-gradient(225deg, var(--paper) 49%, #8e3c4c 50%, #632030 100%);
  box-shadow: -1px 1px 3px rgba(0, 0, 0, .5);
}
.msg.agent::before { background-image: url("library/quill.svg"); }

/* The chips: gilt-lettered labels on green leather. */
.tool {
  color: #e8cc85;
  background: linear-gradient(180deg, #284634, #18301f);
  border-color: rgba(201, 160, 74, .5);
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 230, 170, .1), 0 2px 5px -2px rgba(0, 0, 0, .75);
}
.tool[aria-expanded="true"] { background: linear-gradient(180deg, #18301f, #284634); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .55); }
.tool.failed { color: #f2a9b6; background: linear-gradient(180deg, #4a1822, #36101a); border-color: #7a3040; }
/* What a chip opens: an index card under the lamp. */
.receipt, .md .slip { border-color: #4f3d22; border-left-color: var(--gold); box-shadow: 0 8px 16px -10px rgba(0, 0, 0, .85); }
.receipt { background: linear-gradient(180deg, #2b2118, #211911); }
.receipt .r-cmd { color: #dcc283; }
.receipt .r-out { border-top-color: #4f3d22; }
.md .slip {
  background:
    repeating-linear-gradient(180deg, transparent 0, transparent calc(1.6em - 1px), rgba(201, 160, 74, .13) calc(1.6em - 1px), rgba(201, 160, 74, .13) 1.6em) 0 .7em / 100% calc(100% - 1.4em) no-repeat,
    linear-gradient(180deg, #2b2118, #211911);
}

.recap svg { color: #b8506a; }
.recap svg:nth-child(3) { color: #d6a24a; }
.recap svg:nth-child(2) { color: #8f70cc; }
/* app.js colours these inline. */
.typing svg:nth-child(1) { color: #c4566f !important; }
.typing svg:nth-child(2) { color: #9a7fd6 !important; }
.typing svg:nth-child(3) { color: #d6a24a !important; }

.msg .err, .notice { color: #f2b0bc; background: #3a1119; border-color: #6e2a38; }
.notice { border-left-color: var(--rose); }
.notice.good { color: #c5dba6; background: #16261b; border-color: #35502f; border-left-color: #7f9c6c; }

/* --- markdown --- */
.md ol > li::marker { color: var(--gold-deep); }
.md blockquote { border-left-color: var(--gold); }
.md hr { background: rgba(201, 160, 74, .5); }
.md hr[data-divider], .md .divider { color: #d1aa58; }
.md code { background: #2a1f1a; border-color: #4a3826; color: #d7c1f7; }
.md pre.code { background: #1a130e; border-color: #3e2f20; }
.md th, .md td, .ledger th, .ledger td { border-bottom-color: rgba(201, 160, 74, .25); }
.md th, .ledger th { border-bottom-color: rgba(201, 160, 74, .55); }
.md tbody tr:nth-child(even), .ledger tbody tr:nth-child(even) { background: rgba(201, 160, 74, .06); }

/* --- the inkwell --- */
.composer { background: linear-gradient(180deg, rgba(22, 14, 10, 0), var(--fade) 38%); }
.inkwell {
  background: var(--noise), linear-gradient(180deg, #1d140e, #150e0a);
  border-color: #6b5326;
  box-shadow: inset 0 2px 7px rgba(0, 0, 0, .65), 0 0 0 3px var(--walnut), 0 0 0 4px rgba(201, 160, 74, .5), 0 10px 22px -12px rgba(0, 0, 0, .95);
}
.inkwell:focus-within { box-shadow: inset 0 2px 7px rgba(0, 0, 0, .65), 0 0 0 3px var(--walnut), 0 0 0 5px var(--wisteria), 0 10px 22px -12px rgba(0, 0, 0, .95); }
.inkwell textarea { caret-color: var(--gold-deep); }
.inkwell textarea::placeholder { color: #8a7558; }

/* --- plaques: polished brass, engraved --- */
.plaque {
  color: #2a1a0b;
  text-shadow: 0 1px 0 rgba(255, 238, 196, .5);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, 0) 45%),
    linear-gradient(180deg, #f1d896 0%, #d2a654 44%, #a8792f 56%, #c99a45 100%);
  border-color: #5c3f14;
  box-shadow:
    inset 0 1px 0 rgba(255, 250, 220, .7),
    inset 0 0 0 2px rgba(255, 235, 180, .16),
    0 0 0 2px #24170e,
    0 0 0 3px #8a6a2e,
    0 6px 14px -6px rgba(0, 0, 0, .85);
}
/* Its two diamonds become the screws that hold it. */
.plaque::before, .plaque::after {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fbe9b4, #8a6224 70%);
  box-shadow: 0 0 0 1px rgba(60, 38, 10, .65), inset 0 0 0 .5px rgba(0, 0, 0, .3);
  opacity: 1;
}
.plaque:hover { color: #1e1207; filter: brightness(1.07); }
.plaque:active { box-shadow: inset 0 2px 5px rgba(60, 35, 5, .55), 0 0 0 2px #24170e, 0 0 0 3px #8a6a2e; }
.plaque.quiet {
  color: #e6c477;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .65);
  background: linear-gradient(180deg, #402c1d, #24180f);
  border-color: #8a6a2e;
}
.plaque.quiet:hover { color: #f6dfa0; }

.overline { color: var(--rose-ink); }
.fields input, .fields select {
  color: var(--ink);
  background: linear-gradient(180deg, #1a120d, #140e0a);
  border-color: #6b5326;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .55);
}
.fields input:focus, .fields select:focus { border-color: var(--wisteria); box-shadow: inset 0 2px 5px rgba(0, 0, 0, .55), 0 0 0 3px rgba(179, 154, 230, .35); }
.fields fieldset { border-color: rgba(201, 160, 74, .35); }

/* --- settings: the allowance is a candle's flame left --- */
.gauge {
  background: linear-gradient(180deg, #120c08, #1e150f);
  border-color: #6b5326;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .7), 0 0 0 3px var(--paper), 0 0 0 4px rgba(201, 160, 74, .45);
}
.gauge .fill { background: linear-gradient(180deg, #fff0c4, #f0bf5a 50%, #b8741f); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 0 12px rgba(255, 170, 70, .55); }
.choice {
  background: var(--noise), linear-gradient(180deg, #22180f, #1a120c);
  border-color: #5a4322;
  box-shadow: 0 2px 0 #0d0805, 0 6px 12px -10px #000;
}
.choice:has(input:checked) { background: linear-gradient(180deg, #2e2244, #211833); border-color: var(--wisteria); box-shadow: 0 0 0 1px var(--wisteria), 0 8px 14px -10px #000; }
