/* ============================================================
   LAUREL & LANTERN INN — writers-corner.css (v20, 2026-10-18; v21k candle)
   The Writer's Corner on the Library Hearth page: a parchment page
   on a walnut desk, story-spark cards, a sprint candle, and a
   brainstorm board. Uses only the tokens styles.css defines.
   All motion here stops with "Still the house" or reduced motion
   (magic.css and styles.css handle that site-wide).
   ============================================================ */

.corner { margin-top: 64px; text-align: left; }
.corner h2 { text-align: center; }
.wc-lede { text-align: center; color: var(--parchment-dim); font-size: 1.15rem; max-width: 620px; margin: -12px auto 16px; }
.wc-private {
  max-width: 640px; margin: 0 auto 22px; padding: 14px 18px;
  font-size: 0.98rem; color: var(--parchment-dim); text-align: center;
  border: 1px solid var(--parchment-faint); border-radius: 12px; background: rgba(12, 0, 13, 0.4);
}
.wc-private strong { color: var(--parchment); font-weight: 600; }
.wc-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- buttons ---------- */
.wc-btn, .wc-tool, .wc-music {
  font-family: var(--serif-caps); font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--parchment); background: rgba(12, 0, 13, 0.5);
  border: 1px solid var(--parchment-faint); border-radius: 999px;
  padding: 10px 16px; min-height: 40px; cursor: pointer;
  transition: border-color 0.25s, color 0.25s, background 0.25s;
}
.wc-btn:hover, .wc-btn:focus-visible, .wc-tool:hover, .wc-tool:focus-visible,
.wc-music:hover, .wc-music:focus-visible { border-color: var(--amber); color: var(--amber); }
.wc-btn-quiet { background: none; color: var(--parchment-dim); }
.wc-danger:hover, .wc-danger:focus-visible { border-color: #c96a5a; color: #e08b7c; }
.wc-tool[aria-expanded="true"] { background: var(--amber); border-color: var(--amber); color: var(--night-deep); }
.wc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.wc-music { display: flex; align-items: center; gap: 10px; margin: 0 auto 26px; }
.wc-music[aria-pressed="true"] { border-color: var(--copper); color: var(--copper); }
.wc-note { font-size: 1rem; letter-spacing: 0; }
@media (prefers-reduced-motion: no-preference) {
  .wc-music[aria-pressed="true"] .wc-note { display: inline-block; animation: note-bob 2.4s ease-in-out infinite; }
}
@keyframes note-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

.wc-tools { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 18px; }

/* ---------- panels ---------- */
.wc-panel {
  margin: 0 0 18px; padding: 20px 22px;
  background: rgba(12, 0, 13, 0.5); border: 1px solid var(--parchment-faint); border-radius: 14px;
}
.wc-panel[hidden] { display: none; }
.wc-panel-note { color: var(--parchment-dim); font-style: italic; font-size: 1.02rem; }

/* ---------- story sparks ---------- */
.spark-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 14px; }
.spark {
  position: relative; padding: 16px 16px 18px; border-radius: 10px;
  background: linear-gradient(160deg, rgba(51, 0, 51, 0.9), rgba(12, 0, 13, 0.9));
  border: 1px solid rgba(204, 153, 102, 0.45);
  box-shadow: inset 0 0 0 4px rgba(12, 0, 13, 0.6), inset 0 0 0 5px rgba(204, 153, 102, 0.2);
}
.spark-deck {
  font-family: var(--serif-caps); font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--copper); margin-bottom: 8px;
}
.spark-text { font-size: 1.08rem; line-height: 1.45; }
@media (prefers-reduced-motion: no-preference) {
  .spark { animation: card-turn 0.6s ease-out both; animation-delay: calc(var(--n, 0) * 0.09s); }
}
@keyframes card-turn {
  from { opacity: 0; transform: perspective(600px) rotateY(-70deg); }
  to   { opacity: 1; transform: none; }
}

/* ---------- sprint candle (v21k: Erica's painted candle, alive) ----------
   A painted brass chamberstick and a painted wax column (img/candle/, about 20 KB together,
   fetched only when the candle panel is opened). The wax column is a box that shrinks from the
   top as the sprint runs, so the candle really burns down; a drawn melt pool, wick and flame
   ride its top edge. New drips are added by js/writers-corner.js as it burns.
   Size: the whole candle is 242px tall. Nothing here flickers faster than once every 2 seconds;
   all of it stops with "Still the house" or reduced motion (the flame then simply glows). */
.wc-sprint { display: grid; grid-template-columns: 80px 1fr; gap: 30px; align-items: center; }
.candle { --hold: 126px; --wax: 83px; position: relative; width: 80px; height: 242px; }

.candle-holder { position: absolute; left: 0; bottom: 0; width: 80px; height: 127px; z-index: 2; }
.candle-wax {
  position: absolute; left: 27.5px; bottom: var(--hold); width: 25px; z-index: 1;
  height: calc(var(--wax) * var(--left, 1)); overflow: hidden;
  transition: height 1s linear;
}
.wax-full { position: absolute; left: 0; bottom: 0; width: 25px; height: var(--wax); }
.wax-body { display: block; width: 25px; height: 83px; }
.candle-wax::after {  /* the flame warms the top of the wax */
  content: ""; position: absolute; left: 3.5px; right: 3px; top: 0; height: 30px; pointer-events: none;   /* only across the wax itself */
  background: linear-gradient(rgba(255, 190, 100, 0.5), rgba(255, 190, 100, 0));
  opacity: 0; transition: opacity 0.6s;
}
.wc-sprint.is-lit .candle-wax::after { opacity: 1; }
.candle.is-resetting, .candle.is-resetting * { transition: none !important; }

/* everything that rides the top of the wax sits on one zero-size anchor */
.candle-top {
  position: absolute; left: 40.25px; width: 0; height: 0; z-index: 3;   /* the wax column's own centre */
  bottom: calc(var(--hold) + var(--wax) * var(--left, 1));
  transition: bottom 1s linear;
}
.candle-cap {  /* the little pool of melted wax around the wick */
  position: absolute; left: -9.75px; top: -3.25px; width: 19.5px; height: 6.5px; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 58%, #f0d8a8 0, #e6cb9a 45%, #d0b080 80%, #b99865 100%);
  box-shadow: inset 0 1px 1px rgba(255, 246, 224, 0.7), 0 1px 1.5px rgba(30, 14, 0, 0.45);
}
.candle-cap::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 55%, #fff0c4 0, #ffe099 45%, rgba(255, 200, 110, 0) 82%);
  box-shadow: 0 0 6px 1px rgba(255, 160, 60, 0.5);
  opacity: 0; transition: opacity 0.6s;
}
.wc-sprint.is-lit .candle-cap::after { opacity: 1; }
.candle-wick {
  position: absolute; left: -0.9px; bottom: -1.5px; width: 1.8px; height: 8px; border-radius: 1px 1px 0 0;
  background: linear-gradient(#120b06, #3b2a1b);
}
.candle-flame {
  position: absolute; left: -5px; bottom: 4.5px; width: 10px; height: 24px; overflow: visible;
  transform-origin: 50% 100%; opacity: 0; transition: opacity 0.6s;
}
.candle-flame .cf-body { transform-origin: 50% 100%; transform-box: fill-box; }
.candle-glow {
  position: absolute; left: -45px; bottom: -28px; width: 90px; height: 90px; pointer-events: none;
  mix-blend-mode: screen; opacity: 0; transition: opacity 0.8s;
}
.candle-glow::before {  /* a wide, faint halo */
  content: ""; position: absolute; inset: -45px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 153, 51, 0.14), rgba(255, 153, 51, 0) 70%);
}
.candle-glow::after {  /* the close warm glow */
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 170, 70, 0.42) 0, rgba(255, 153, 51, 0.18) 38%, rgba(255, 153, 51, 0) 70%);
}
.wc-sprint.is-lit .candle-flame, .wc-sprint.is-lit .candle-glow { opacity: 1; }

/* drips, added as the candle burns (js/writers-corner.js) */
.candle-drip {
  position: absolute; width: var(--w, 3px); height: 0; border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, #cbb083, #fff3da 38%, #f1ddb7 68%, #cdb386);
  transition: height var(--t, 14s) cubic-bezier(0.3, 0.55, 0.4, 1);
}
.candle-drip::after {
  content: ""; position: absolute; left: 50%; bottom: -1.2px;
  width: calc(var(--w, 3px) * 1.6); height: calc(var(--w, 3px) * 1.7); margin-left: calc(var(--w, 3px) * -0.8);
  border-radius: 50% 50% 50% 50% / 45% 45% 55% 55%;
  background: radial-gradient(circle at 36% 30%, #fffcf3 0 12%, #f7e8c8 42%, #dcc392 100%);
  box-shadow: 0 0.5px 1px rgba(90, 55, 20, 0.35);
}

@media (prefers-reduced-motion: no-preference) {
  .wc-sprint.is-lit .candle-flame { animation: candle-sway 3.4s ease-in-out infinite; }
  .wc-sprint.is-lit .candle-flame .cf-body { animation: candle-lick 2.3s ease-in-out infinite; }
  .wc-sprint.is-lit .candle-glow::after { animation: candle-breathe 4.3s ease-in-out infinite; }
}
@keyframes candle-sway {
  0%, 100% { transform: rotate(-1.2deg) scale(1, 1); }
  22% { transform: rotate(1.6deg) scale(0.97, 1.04); }
  47% { transform: rotate(-0.4deg) scale(1.02, 0.98); }
  71% { transform: rotate(1.1deg) scale(0.98, 1.05); }
}
@keyframes candle-lick {
  0%, 100% { transform: scale(1, 1); }
  31% { transform: scale(0.94, 1.07); }
  58% { transform: scale(1.04, 0.95); }
  83% { transform: scale(0.97, 1.04); }
}
@keyframes candle-breathe { 0%, 100% { opacity: 0.9; } 35% { opacity: 1; } 70% { opacity: 0.8; } }

@media (max-width: 560px) {  /* on a phone the candle stands above its words */
  .wc-sprint { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 16px; }
  .wc-sprint .wc-actions { justify-content: center; }
}
.sprint-status { margin-top: 10px; font-size: 1.1rem; }
.sprint-status strong { color: var(--amber); font-weight: 600; }

/* ---------- the desk and its page ---------- */
.wc-desk {
  position: relative; padding: 18px 18px 14px; border-radius: 16px;
  background:
    radial-gradient(120% 80% at 85% 0%, rgba(255, 153, 51, calc(0.08 + var(--glow, 0) * 0.14)), rgba(255, 153, 51, 0) 60%),
    linear-gradient(180deg, #3a2414, #2a190d);
  border: 1px solid rgba(204, 153, 102, 0.35);
  box-shadow: 0 18px 44px rgba(12, 0, 13, 0.55);
  transition: background 1.2s ease;
}
.wc-pages { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.wc-pages select {
  font-family: var(--serif-display); font-size: 1.02rem; color: var(--parchment);
  background: rgba(12, 0, 13, 0.6); border: 1px solid var(--parchment-faint); border-radius: 8px;
  padding: 8px 10px; min-height: 40px; max-width: 100%;
}
.paper {
  position: relative; border-radius: 4px; padding: 26px 30px 28px 52px;
  background: #F3E7D6;
  box-shadow: 0 2px 0 #e2d2b8, 0 4px 0 #d8c6a8, inset 0 0 60px rgba(164, 106, 49, 0.18);
}
.paper::before {  /* the margin rule */
  content: ""; position: absolute; top: 0; bottom: 0; left: 38px; width: 1px; background: rgba(122, 0, 89, 0.28);
}
.paper-title, .paper-body {
  display: block; width: 100%; border: 0; outline: none; background: transparent;
  color: #2b1622; font-family: var(--serif-display);
}
.paper-title { font-size: 1.6rem; font-weight: 600; margin-bottom: 8px; padding: 2px 0; }
.paper-body {
  font-size: 1.2rem; line-height: 2rem; min-height: 22rem; resize: vertical;
  background-image: linear-gradient(transparent calc(2rem - 1px), rgba(0, 102, 102, 0.20) calc(2rem - 1px));
  background-size: 100% 2rem; background-attachment: local;
}
.paper-title::placeholder, .paper-body::placeholder { color: rgba(43, 22, 34, 0.42); font-style: italic; }
.paper-title:focus-visible, .paper-body:focus-visible { box-shadow: 0 0 0 2px rgba(0, 102, 102, 0.35); border-radius: 2px; }
.wc-status {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px;
  font-family: var(--serif-caps); font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--parchment-dim);
}
.wc-saved { color: var(--copper); }

/* ---------- brainstorm board ---------- */
.wc-board { margin-top: 18px; }
.board-add { display: flex; gap: 10px; margin-top: 14px; }
.board-add input {
  flex: 1; min-width: 0; font-family: var(--serif-display); font-size: 1.05rem; color: var(--parchment);
  background: rgba(12, 0, 13, 0.6); border: 1px solid var(--parchment-faint); border-radius: 999px; padding: 9px 16px;
}
.board-add input:focus-visible { outline: none; border-color: var(--amber); }
.board-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0 6px; }
.board-bar .chip { padding: 7px 14px; font-size: 0.66rem; }
.board-cards {
  list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 10px;
}
.idea {
  --tint: var(--parchment-faint);
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  padding: 14px 14px 10px; border-radius: 10px; min-height: 120px;
  background: rgba(243, 231, 214, 0.06); border: 1px solid var(--tint); border-top: 3px solid var(--tint);
}
.idea[data-group="copper"] { --tint: var(--copper); }
.idea[data-group="teal"] { --tint: #4D9E9E; }
.idea[data-group="plum"] { --tint: #b0559a; }
.idea.is-pinned { box-shadow: 0 0 0 1px var(--amber), 0 10px 26px rgba(255, 153, 51, 0.10); }
.idea-text { font-size: 1.05rem; line-height: 1.4; overflow-wrap: anywhere; }
.idea-tools { display: flex; flex-wrap: wrap; gap: 2px; }
.idea-tools button {
  font-family: var(--serif-caps); font-size: 0.58rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--parchment-dim); background: none; border: 0; border-radius: 6px; padding: 7px 6px; min-height: 32px; cursor: pointer;
}
.idea-tools button:hover, .idea-tools button:focus-visible { color: var(--amber); background: rgba(255, 153, 51, 0.08); }
.idea-tools .pin[aria-pressed="true"] { color: var(--amber); }
.board-empty { color: var(--parchment-dim); font-style: italic; margin-top: 10px; }
@media (prefers-reduced-motion: no-preference) {
  .idea.is-new { animation: line-in 0.45s ease-out both; }
}

.wc-foot { display: flex; justify-content: center; margin-top: 20px; }
.wc-warn {
  margin-top: 14px; padding: 12px 16px; border-radius: 10px; text-align: center;
  border: 1px solid rgba(255, 153, 51, 0.5); color: var(--parchment); background: rgba(255, 153, 51, 0.08);
}

/* ---------- phones ---------- */
@media (max-width: 600px) {
  .paper { padding: 20px 16px 22px 34px; }
  .paper::before { left: 24px; }
  .paper-body { min-height: 18rem; }
  .wc-desk { padding: 14px 10px 12px; }
  .board-add { flex-direction: column; }
}

/* ---------- v21j: throwing a page in the fire ---------- */
.wc-desk { position: relative; }
.wc-ask {
  position: absolute; left: 50%; top: 96px; transform: translateX(-50%); z-index: 5;
  width: min(92%, 420px); padding: 20px 22px 18px; text-align: center; border-radius: 6px;
  background: linear-gradient(180deg, #F6ECDC, #EADBC2); color: #2b1622;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(164, 106, 49, 0.4);
}
.wc-ask-q { font-family: var(--serif-display); font-size: 1.3rem; font-weight: 600; margin: 0; color: #330033; }
.wc-ask-d { margin: 6px 0 0; font-style: italic; color: #5A3A24; }
.wc-ask-btns { display: flex; gap: 10px; justify-content: center; margin: 14px 0 0; flex-wrap: wrap; }
.wc-ask .wc-btn { background: transparent; }
.wc-ask .wc-ask-keep { color: #330033; border: 1px solid rgba(51, 0, 51, 0.55); background: rgba(255, 255, 255, 0.35); }
.wc-ask .wc-ask-keep:focus-visible { outline: 2px solid #006666; outline-offset: 2px; }
.wc-ask .wc-ask-burn { color: #7A0059; }
.wc-undo { display: inline-flex; gap: 10px; align-items: center; color: var(--parchment); }
.wc-undo[hidden] { display: none; }
.wc-undo-btn {
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--amber);
  background: none; border: 1px solid rgba(255, 153, 51, 0.5); border-radius: 999px; padding: 6px 12px; cursor: pointer;
}
.wc-undo-btn:hover, .wc-undo-btn:focus-visible { color: var(--parchment); border-color: var(--amber); }

/* the page copy that crumples and flies */
.wc-ghost { position: fixed !important; margin: 0 !important; z-index: 95; pointer-events: none; transform-origin: 50% 50%; overflow: hidden; will-change: transform; }
.wc-ghost .wc-label { display: none; }
/* creases: facets of light and shadow that deepen as the page crumples, then char as it burns */
.wc-ghost::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.5s ease-in;
  background:
    conic-gradient(from 12deg at 38% 42%, rgba(60,30,10,.42), rgba(255,250,235,.35) 8%, rgba(60,30,10,.3) 17%, rgba(255,250,235,.25) 26%,
      rgba(60,30,10,.45) 37%, rgba(255,250,235,.3) 49%, rgba(60,30,10,.35) 61%, rgba(255,250,235,.2) 72%, rgba(60,30,10,.4) 86%, rgba(60,30,10,.42)),
    conic-gradient(from 200deg at 66% 64%, rgba(60,30,10,.35), rgba(255,250,235,.25) 12%, rgba(60,30,10,.4) 28%, rgba(255,250,235,.2) 45%,
      rgba(60,30,10,.35) 63%, rgba(255,250,235,.3) 80%, rgba(60,30,10,.35)),
    radial-gradient(circle at 35% 30%, rgba(255,255,255,.35), rgba(0,0,0,0) 40%),
    radial-gradient(circle at 50% 50%, rgba(0,0,0,0) 45%, rgba(40,20,5,.55) 100%);
  background-blend-mode: multiply, multiply, screen, normal;
}
.wc-ghost.is-crumpling::after { opacity: 1; }
.wc-ghost.is-charring { transition: filter 0.38s ease-in; filter: brightness(0.25) sepia(1) saturate(3) !important; }

/* the little hearth that glows up at the bottom of the screen */
.wc-hearth {
  position: fixed; left: 50%; bottom: 0; z-index: 94; width: 220px; height: 150px; margin-left: -110px;
  pointer-events: none; animation: hearth-up 0.45s cubic-bezier(.2,.7,.3,1) both;
}
.wc-hearth.is-out { animation: hearth-down 0.6s ease-in both; }
@keyframes hearth-up { from { transform: translateY(100%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes hearth-down { to { transform: translateY(100%); opacity: 0; } }
.wc-hearth-arch {
  position: absolute; left: 10px; right: 10px; bottom: 0; height: 128px;
  border-radius: 100px 100px 0 0; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(255, 170, 80, 0.55), rgba(40, 8, 10, 0.95) 70%),
    #1a0605;
  box-shadow: 0 0 0 12px #3B2216, 0 0 0 14px #C9A24A, 0 0 0 26px #2A170C, 0 -10px 40px rgba(255, 140, 50, 0.35);
}
.wc-hearth-fire { position: absolute; left: 0; right: 0; bottom: 6px; height: 90px; }
.wc-hearth-fire i {
  position: absolute; bottom: 0; width: 46px; height: 70px; border-radius: 50% 50% 46% 46% / 64% 64% 36% 36%;
  background: radial-gradient(ellipse at 50% 85%, #FFF4C8 0%, #FFC25E 30%, #FF7A1F 60%, rgba(200, 40, 10, 0) 78%);
  transform-origin: 50% 100%; animation: flame 0.9s ease-in-out infinite alternate;
}
.wc-hearth-fire i:nth-child(1) { left: 42px; animation-delay: -0.3s; height: 58px; }
.wc-hearth-fire i:nth-child(2) { left: 77px; width: 52px; height: 80px; }
.wc-hearth-fire i:nth-child(3) { left: 116px; animation-delay: -0.6s; height: 62px; }
@keyframes flame { from { transform: scaleY(0.9) skewX(-3deg); opacity: 0.88; } to { transform: scaleY(1.06) skewX(3deg); opacity: 1; } }
.wc-hearth.is-flare .wc-hearth-fire i { animation: flare 0.6s ease-out forwards; }
@keyframes flare { 0% { transform: scaleY(1); } 35% { transform: scaleY(1.45) scaleX(1.15); } 100% { transform: scaleY(1); } }
.wc-hearth-glow {
  position: absolute; left: -60px; right: -60px; bottom: -20px; height: 120px;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 150, 60, 0.35), rgba(255, 150, 60, 0) 70%);
}
.wc-ember {
  position: fixed; z-index: 96; width: 4px; height: 4px; border-radius: 50%; pointer-events: none;
  background: #FFC25E; box-shadow: 0 0 6px 2px rgba(255, 150, 60, 0.7);
  animation: ember 1.3s ease-out var(--d, 0s) forwards; opacity: 0;
}
@keyframes ember { 0% { opacity: 0; transform: translate(0, 0); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)); } }

/* motion off: a quiet fade with a warm glow */
.paper.is-burning-still { transition: opacity 0.4s ease, box-shadow 0.4s ease; opacity: 0.2; box-shadow: 0 0 40px 10px rgba(255, 150, 60, 0.45); }
html.is-still .paper.is-burning-still { opacity: 0.2; }
