/* Lamp
 *
 * The page is a wall, styled as if fully lit. The canvas laid over it is the darkness:
 * transparent where the lamp's light lands, black where it does not.
 */

:root {
    --wall: #c79a70;
    --ink: #26170d;
    --paper: #f3e6cd;
    --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
    margin: 0;
    box-sizing: border-box;
}

html {
    background: var(--wall);
    color: var(--ink);
    font-family: var(--sans);
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
}

/* The wall and what hangs on it */
.wall {
    min-height: 100dvh;
    padding: 45vh max(20px, 6vw) 14vh;
    padding-block: 45dvh 14dvh;  /* the lamp hangs above; the desk has the bottom of the page */
    display: grid;
    align-content: start;
    justify-items: center;
    gap: clamp(16px, 3.2dvh, 36px);
    text-align: center;
}

h1 {
    font: italic 400 clamp(2.6rem, 7.4vw, 6.2rem) / 0.95 var(--serif);
    letter-spacing: -0.02em;
}

.lede {
    max-width: 34ch;
    margin: 0.9em auto 0;
    font-size: clamp(0.95rem, 1.4vw, 1.1rem);
    line-height: 1.45;
    text-wrap: balance;
    color: rgb(38 23 13 / 0.8);  /* not opacity: that is animated when the words vanish */
}

/* A few seconds after the page opens the words leave the wall. ash.js draws them
   blowing away; where it cannot (reduced motion, no WebGL) they simply fade. */
.wordless h1,
.wordless .lede {
    opacity: 0;
}

.wordless.gently h1,
.wordless.gently .lede {
    transition: opacity 1.8s;
}

.plaques {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 11.5rem));
    gap: clamp(10px, 1.6vw, 22px);
}

.plaque {
    padding: 0.85rem 1rem 0.95rem;
    border-radius: 6px;
    background: var(--paper);
    text-align: left;
}

.plaque dt {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0.6;
}

.plaque dd {
    margin-top: 0.3rem;
    font: 400 clamp(1.7rem, 3vw, 2.4rem) / 1.1 var(--serif);
    font-variant-numeric: tabular-nums;
}

/* The lamp */
#ash,
#scene {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Invisible; script lays it along the chain, pivoting on the knob at its lower end */
#cord {
    position: fixed;
    top: 0;
    left: 0;
    width: 48px;
    height: 48px;
    transform-origin: 24px calc(100% - 24px);
    border: 0;
    border-radius: 24px;
    background: none;
    color: transparent;
    font-size: 0;
    cursor: grab;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

#cord:active {
    cursor: grabbing;
}

#cord:focus-visible {
    outline: 2px solid #ffdca8;
    outline-offset: 2px;
}

/* A word beside the knob until the first pull, because an unlit wall explains nothing */
#cord::after {
    content: "pull";
    position: absolute;
    bottom: 12px;
    left: 100%;
    translate: 2px 0;
    font: italic 1.05rem var(--serif);
    color: #f4d7a4;
    opacity: 0;
    transition: opacity 0.6s;
    pointer-events: none;
}

.hint:not(.on) #cord::after {
    opacity: 0.85;
}

#notice {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    translate: -50% 0;
    padding: 0.5em 1.1em;
    border-radius: 999px;
    background: rgb(20 14 10 / 0.78);
    color: #f4e3c6;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.4s;
    pointer-events: none;
}

#notice.show {
    opacity: 1;
}

@media (max-width: 640px) {
    .plaques {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Without WebGL there is no lamp to draw: a plain page with a plain switch */
.plain #scene {
    display: none;
}

.plain #cord {
    top: 22dvh;
    left: 50%;
    width: auto;
    height: auto;
    translate: -50% 0;
    padding: 0.7em 1.4em;
    border: 1px solid;
    border-radius: 999px;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

/* No light to show the state, so say it */
.plain #cord::after {
    content: ": off";
    position: static;
    translate: none;
    font: inherit;
    color: inherit;
    opacity: 1;
}

.plain.on #cord::after {
    content: ": on";
}

.plain:not(.on) {
    --wall: #17110d;
    --ink: #a59682;
    --paper: #261c15;
}
