*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* Courier is for the script's words, which ask for it by name; everything else is in the UI font. */
body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--desk);
  color: var(--chrome);
  font-family: var(--font-ui);
  font-size: 16px;
}

/* Every Writer room is green leather under the banker's lamp: a touch of green glass at the very top,
   then the bulb's warm pool, falling off to the edges. The grain is drawn, so it costs no download. */
body:not(.producer, .landing-page) {
  --leather-grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='l'><feTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2' seed='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0.55 0 0 0 -0.12'/></filter><rect width='100%' height='100%' filter='url(%23l)'/></svg>");
  background:
    linear-gradient(rgb(255 236 200 / var(--room-sun, 0)) 0 0),
    radial-gradient(ellipse 30% 14% at 50% 0%, rgb(70 170 110 / 0.24), transparent 75%),
    radial-gradient(ellipse var(--lamp-pool, 55% 42%) at 50% 8%, rgb(255 205 130 / var(--lamp-glow, 0.22)), transparent 74%),
    radial-gradient(ellipse 130% 95% at 50% 25%, transparent var(--room-reach, 50%), rgb(0 0 0 / var(--room-dark, 0.45))),
    var(--leather-grain),
    linear-gradient(var(--leather), var(--leather-deep));
  background-attachment: fixed;
  background-color: var(--leather-deep);
}

/* The room keeps time (room_light): late at night the lamp's pool draws in and the corners go dark; around noon
   the room is lit and the pool spreads. Set as the page is drawn; nothing moves. */
body[data-room=late] { --lamp-pool: 36% 30%; --blotter-pool: 45% 38%; --lamp-glow: 0.32; --room-reach: 28%; --room-dark: 0.68; --room-shade: 0.5; }
body[data-room=noon] { --lamp-pool: 90% 75%; --blotter-pool: 100% 80%; --lamp-glow: 0.16; --room-reach: 70%; --room-dark: 0.2; --room-sun: 0.07; }

a { color: inherit; }

code { font-family: var(--font-typed); }

:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.45em 0.9em;
  border: 2px solid var(--accent);
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 var(--text-md) var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.button--quiet { background: transparent; color: var(--chrome); border-color: var(--chrome-muted); }
.button--danger { background: transparent; color: var(--danger-on-dark); border-color: var(--danger); }
.button:hover { filter: brightness(1.1); }

form.button_to { display: inline; }
form.button_to[hidden] { display: none; }

.flash {
  position: fixed;
  inset: auto 1rem 1rem auto;
  z-index: 20;
  margin: 0;
  padding: 0.6em 1em;
  border-radius: var(--radius-control);
  background: var(--chrome);
  color: var(--desk);
  box-shadow: var(--shadow-menu);
}

.flash--dismissable {
  max-width: min(28rem, calc(100vw - 2rem));
  cursor: pointer;
}

.desk {
  container-type: inline-size;
  padding: 2rem 16px 6rem;
}

.desk--centered {
  display: grid;
  justify-items: center;
  gap: 2rem;
}

.desk__empty {
  max-width: 32rem;
  margin: 4rem auto;
  color: var(--chrome-muted);
  text-align: center;
  font-family: var(--font-hand);
  font-size: 1.3rem;
}

.desk__section {
  max-width: 64rem;
  margin: 3rem auto 0;
  color: var(--chrome-muted);
  font: 1.4rem var(--font-hand);
}

.desk__section-empty { max-width: 64rem; margin: 0.5rem auto 0; color: var(--chrome-muted); font-family: var(--font-hand); }

/* One row on every screen: Scrawl's name, then the bar's actions pushed right, then the menu (☰) in the corner. */
.desk-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 16px 0;
}
.desk-header__brand { flex: none; }
.desk-header__actions { flex: 1 1 auto; justify-content: flex-end; min-width: 0; }
.desk-header > .desk-header__account { flex: none; }

/* The banker's lamp hangs over the top left corner of the desk, as on the landing page, and Scrawl's name sits
   beside it in the same brass-lit hand with its yarn already strung (it's strung once, on the landing page). */
.desk-header { position: relative; }
.desk-header__lamp { position: absolute; z-index: 1; top: -0.5rem; left: 0; width: clamp(8rem, 17vw, 13rem); height: auto; overflow: visible; pointer-events: none; }

.desk-header__brand {
  margin: 0 0 0 clamp(6.5rem, 14vw, 10.5rem);
  line-height: 0;
}
.desk-header__brand .wordmark { width: clamp(9rem, 16vw, 13rem); margin: -0.5rem 0 -0.25rem; }
/* It fades up looking at us and then swings down onto the desk once (lamp_controller.js), as on the landing page. */
.desk-header__lamp { animation: desk-lamp-up 0.6s ease-out 1 backwards; }
@keyframes desk-lamp-up { from { opacity: 0; } }
/* Just signed in, the whole room fades up from black, slowly, and the lamp with it before it swings down. */
html:has(body.lights-up) { background: #000; }
body.lights-up { animation: lights-up 2.2s ease-in-out 1 backwards; }
body.lights-up .desk-header__lamp { animation-duration: 2.2s; }
@keyframes lights-up { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { body.lights-up, .desk-header__lamp { animation: none; } }
.wordmark--still :is(.wordmark__strand, .wordmark__strand-shadow, .wordmark__pin) { animation: none; }

.desk-header__actions, .desk-header__menu { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

/* The header scrolls away, so its menu hangs from the top of the page rather than the screen. It's always a
   dropdown, opened from the person's name (the ☰ on phones). */
.desk-header__menu--account.bar-menu[popover]:not(:popover-open) { display: none; }
.desk-header__menu.bar-menu[popover]:popover-open { position: absolute; top: 4.25rem; right: 16px; min-width: 15rem; }
.desk-header .desk-header__account { display: inline-flex; align-items: center; gap: 0.5em; padding: 0.35em 0.55em; background: transparent; font-size: var(--text-md); }
.desk-header .desk-header__account:hover, .desk-header .desk-header__account:has(+ :popover-open) { background: var(--desk-light); }
.desk-header .desk-header__account svg { display: block; width: 1.2rem; height: 1.2rem; }

/* Like the script's bar: plain words until hovered, with only New script filled in, in brass. */
.desk-header .button { padding: 0.35em 0.75em; border: 0; font-size: var(--text-md); }
.desk-header .button:not(.button--quiet) { margin-right: 0.5rem; background: var(--brass); color: var(--brass-ink); }
.desk-header .button--quiet { background: transparent; color: var(--chrome); font-weight: 500; }
.desk-header .button--quiet:hover { background: var(--desk-light); filter: none; }

/* What's on the bar and what's in the menu, by the screen's width. */
@media (width < 38rem) { .desk-header .desk-header__from-38 { display: none; } }
@media (width < 62rem) { .desk-header .desk-header__from-62, .desk-header__who { display: none; } }
@media (width < 70rem) { .desk-header .desk-header__from-70 { display: none; } }
@media (width < 78rem) { .desk-header .desk-header__from-78 { display: none; } }
@media (width >= 38rem) { .desk-header__menu .desk-header__until-38 { display: none; } }
@media (width >= 62rem) { .desk-header__menu .desk-header__until-62 { display: none; } }
@media (width >= 70rem) { .desk-header__menu .desk-header__until-70 { display: none; } }
@media (width >= 78rem) { .desk-header__menu .desk-header__until-78 { display: none; } }

/* On a phone the lamp and Scrawl's name come down a size to leave the ticket room. */
@media (width < 30rem) {
  .desk-header { gap: 0.4rem; padding-inline: 10px; }
  .desk-header__lamp { width: 6.5rem; }
  .desk-header__brand { margin-left: 5rem; }
  .desk-header__brand .wordmark { width: 7rem; }
  .desk-header .desk-header__account { padding: 0.4em; }
}
@media (width < 24rem) {
  .desk-header__lamp { width: 5.5rem; }
  .desk-header__brand { margin-left: 4.2rem; }
  .desk-header__brand .wordmark { width: 6rem; }
}

.revision__swatch { display: inline-block; width: 0.9em; height: 0.9em; margin-right: 0.5em; border: 1px solid rgb(0 0 0 / 0.3); border-radius: 2px; background: var(--revision-color); vertical-align: -0.1em; }

.desk-header__brand a { color: inherit; text-decoration: none; }

/* All screenplays: the partners' desk itself, mahogany round the edge, and the scripts lying on its green
   leather blotter in the middle, edged with a gold tooled line. */
body:has(.desk-header) {
  background:
    linear-gradient(rgb(255 236 200 / var(--room-sun, 0)) 0 0),
    radial-gradient(ellipse 130% 95% at 50% 25%, transparent var(--room-reach, 50%), rgb(0 0 0 / var(--room-shade, 0))),
    radial-gradient(ellipse 30% 14% at 50% 0%, rgb(70 170 110 / 0.2), transparent 75%),
    radial-gradient(ellipse var(--lamp-pool, 55% 42%) at 50% 10%, rgb(255 205 130 / var(--lamp-glow, 0.22)), transparent 74%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='700'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.0025 0.07' numOctaves='4' seed='11' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.05  0 0 0 0 0.02  0 0 0 0 0.0  1.1 0 0 0 -0.42'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>"),
    linear-gradient(#45261a, #200f09);
  background-attachment: fixed;
}

body:has(.desk-header) main.desk {
  position: relative;
  max-width: 70rem;
  margin: 0.5rem auto 2rem;
  padding: 1.75rem clamp(1rem, 3vw, 2.5rem) 3rem;
  border-radius: 5px;
  background:
    linear-gradient(rgb(255 236 200 / var(--room-sun, 0)) 0 0),
    radial-gradient(ellipse 120% 110% at 50% 0%, transparent var(--room-reach, 50%), rgb(0 0 0 / var(--room-shade, 0))),
    radial-gradient(ellipse var(--blotter-pool, 70% 50%) at 50% 0%, rgb(255 205 130 / 0.14), transparent 75%),
    var(--leather-grain),
    linear-gradient(var(--leather), var(--leather-deep));
  box-shadow: inset 0 2px 16px rgb(0 0 0 / 0.55), 0 0 0 2px #120a06, 0 18px 40px rgb(0 0 0 / 0.5);
}

/* The gold tooling: a fine line with a fainter one just inside it. */
body:has(.desk-header) main.desk::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgb(201 161 74 / 0.4);
  border-radius: 3px;
  outline: 1px solid rgb(214 175 90 / 0.8);
  outline-offset: 3px;
  pointer-events: none;
}

@media (max-width: 40rem) {
  body:has(.desk-header) main.desk { margin-inline: 8px; padding-inline: 12px; }
}
