/* The writer's desk look (Product::Themed), after Writers Building: green leather under a green-glass
   banker's lamp, with brass for buttons and links. The forms, guides and help booklets lie on the desk as
   cream paper with a paper clip, and coffee rings and a pencil sit around them
   (products/themes/_writers_desk). It's the same look in light and dark mode, because it's a room. Nothing
   moves except the lamp, which swings down once. */
.theme-writers-desk {
  --paper: #13291d;
  --paper-deep: #0e1f16;
  --surface: #2c1910;
  --ink: #f3ead6;
  --ink-soft: #c9b893;
  --line: #5a4526;
  --accent: #d6aa4f;
  --accent-deep: #e8c27a;
  --accent-pale: #3a2c14;
  --on-accent: #1d120b;
  --coral: #f08a6c;
  --coral-pale: #4a261c;
  --mint: #5cc994;
  --mint-pale: #173a2a;
  --amber: #f2c14e;
  --amber-pale: #3d3218;
  --danger: #ffb4ab;
  --shadow-pop: 0 3px 0 #0b0604;

  /* The leather's grain is drawn, so it costs no download. */
  --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>");

  /* The lamp's warm pool falls down and to the right of its shade, fading into dark corners. */
  background:
    radial-gradient(ellipse 60rem 42rem at 16rem 10rem, rgb(255 199 107 / 0.3), rgb(226 128 29 / 0.1) 45%, transparent 72%),
    radial-gradient(ellipse 130% 95% at 30% 20%, transparent 45%, rgb(0 0 0 / 0.5)),
    var(--leather-grain),
    linear-gradient(#224330, #13291d);
  background-attachment: fixed;
  background-color: #13291d;
  color-scheme: dark;
}

/* Paper on the desk takes paper's colours: dark ink, green-glass buttons and links. */
.theme-writers-desk :is(.sheet, .booklet, .guide) {
  --paper: #f1e8d3;
  --paper-deep: #e6dbc2;
  --surface: #fffbf0;
  --ink: #241f19;
  --ink-soft: #61574a;
  --line: #cdbf9f;
  --accent: #1f4a35;
  --accent-deep: #1f4a35;
  --accent-pale: #e3ecdf;
  --on-accent: #f8f1e0;
  --coral: #c4492e;
  --coral-pale: #fbe1d7;
  --mint: #277a56;
  --mint-pale: #d7efe2;
  --amber: #f2b632;
  --amber-pale: #fbefcc;
  --danger: #a3261b;
  --shadow-pop: 0 3px 0 #241f19;
  color: var(--ink);
  color-scheme: light;
}

.theme-writers-desk :is(.sheet, .guide) {
  position: relative;
  border: 0;
  border-radius: 4px;
  background: #f8f1e0;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 22px 46px rgb(0 0 0 / 0.5);
}

/* Sheets lie a little askew, as paper does when it's put down by hand. */
.theme-writers-desk .sheet { rotate: -0.6deg; }
.theme-writers-desk .sheet + .sheet { rotate: 0.5deg; }

.theme-writers-desk .guide { max-width: 52rem; margin: 0 auto 1.5rem; padding: clamp(1.25rem, 4vw, 3rem); text-align: left; rotate: -0.3deg; }

/* A brass paper clip holds the top of the first sheet in a stack. */
.theme-writers-desk .sheet:not(.sheet + .sheet)::before {
  content: "";
  position: absolute;
  top: -0.9rem;
  right: 2.25rem;
  width: 1.1rem;
  height: 3.2rem;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 64'><path d='M15 20 V52 a5 5 0 0 1 -10 0 V8 a4 4 0 0 1 8 0 V46 a1.5 1.5 0 0 1 -3 0 V14' fill='none' stroke='%23b08a3c' stroke-width='2.6' stroke-linecap='round'/></svg>") no-repeat center / contain;
  filter: drop-shadow(1px 2px 1px rgb(0 0 0 / 0.35));
  rotate: 6deg;
}

/* Buttons keep a dark edge on the desk and on paper. */
.theme-writers-desk .button { border-color: #1d120b; }
.theme-writers-desk .button:hover { box-shadow: 0 4px 0 #0b0604; }
.theme-writers-desk .button:active { box-shadow: 0 0 0 #0b0604; }

/* Headings are typed, words beside things are handwritten. */
.theme-writers-desk h1 { font-family: "Special Elite", "Courier New", monospace; font-weight: 400; letter-spacing: 0.01em; }
.theme-writers-desk .public__card > h1 { color: #f3ead6; text-shadow: 0 2px 24px rgb(0 0 0 / 0.45); }
.theme-writers-desk .site-footer { font: 600 1.15rem var(--font-hand); color: var(--ink-soft); }

.theme-writers-desk .app-header { border-bottom-color: rgb(201 161 74 / 0.5); }

/* The scenery lies on the desk behind everything. */
.desk-scenery {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.desk-scenery__lamp {
  position: absolute;
  top: -0.5rem;
  left: 0;
  width: clamp(7rem, 20vw, 17rem);
  height: auto;
  overflow: visible;
  animation: desk-lamp-up 0.8s ease-out 1 backwards;
}

/* Under the portal's header, the lamp hangs from just below it. */
.theme-writers-desk:has(.app-header) .desk-scenery__lamp { top: 3rem; }

@keyframes desk-lamp-up { from { opacity: 0; } }

/* Two rings where a mug was put down twice, low on the right, and a fainter one on the left. */
.desk-scenery__rings {
  position: absolute;
  right: clamp(-4rem, -2vw, -1rem);
  bottom: clamp(-3rem, -2vw, -1rem);
  width: clamp(11rem, 22vw, 18rem);
  rotate: 8deg;
}

.desk-scenery__ring--stray {
  position: absolute;
  top: 58%;
  left: clamp(-3rem, -1vw, 0rem);
  width: clamp(7rem, 12vw, 10rem);
  rotate: -24deg;
}

.desk-scenery__pencil {
  position: absolute;
  bottom: clamp(1.5rem, 6vh, 4rem);
  left: clamp(1rem, 6vw, 6rem);
  width: clamp(9rem, 16vw, 14rem);
  rotate: -14deg;
}

/* On a phone the page fills the desk, so the scenery steps back to its corners. */
@media (max-width: 720px) {
  .desk-scenery__pencil, .desk-scenery__ring--stray { display: none; }
  .desk-scenery__rings { opacity: 0.7; }
}

@media (prefers-reduced-motion: reduce) {
  .desk-scenery__lamp { animation: none; }
}

/* How much of the desk the page takes: all of it on a phone, starting below the lamp rather than under it;
   a wider sheet on a tablet; and two thirds of the desk on a laptop, leaving the lamp, rings and pencil
   their margins. Past a laptop's width the sheet stops growing, so lines stay readable on a big monitor. */
@media (max-width: 720px) {
  .theme-writers-desk .public { padding-top: 6.5rem; }
}

@media (min-width: 721px) {
  .theme-writers-desk .public__card { width: min(100%, 40rem); }
  .theme-writers-desk .public__card > p:not(.public__crumbs) { margin-inline: auto; }
  .theme-writers-desk .guide { max-width: none; }
}

@media (min-width: 1024px) {
  .theme-writers-desk .public--wide { justify-items: center; }
  .theme-writers-desk .public__card { width: min(66.667vw, 75rem); }

  /* On a sheet that wide, name and email sit side by side. */
  .theme-writers-desk .public__card .sheet form { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1.25rem; }
  .theme-writers-desk .public__card .sheet form > * { grid-column: 1 / -1; }
  .theme-writers-desk .public__card .sheet form > .field:has([autocomplete="name"], [autocomplete="email"]) { grid-column: auto; }
  .theme-writers-desk .public__card .sheet form > .button { justify-self: start; }
}
