/*
    board.css — the cork bulletin board, its pinned paintings and sticky notes, and the
    sticky-note drawing pad. Used by paintings.html and by Hanna's admin (Bulletin board page),
    so both show exactly the same board.

    Sizes inside the board use cqw (1% of the board's width), so the whole board scales as one
    picture and a note sits in the same place on every screen. Positions come from the data
    (left/top = the item's center in %; see js/board-tools.js).
*/

/* ---------- The board ---------- */

.cork-scroll {
    /* Its own stacking context: the pinned photos and notes can never paint above a sticky header. */
    position: relative;
    z-index: 0;
    isolation: isolate;
    margin-top: 1.2rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border-radius: 24px;
    -webkit-overflow-scrolling: touch;
}

.cork-board {
    position: relative;
    container-type: inline-size;
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border: 14px solid #8A5A36;
    border-radius: 24px;
    background-color: #C49A6C;
    background-image:
        radial-gradient(rgba(90, 50, 20, 0.35) 1px, transparent 1.5px),
        radial-gradient(rgba(255, 240, 210, 0.35) 1px, transparent 1.5px);
    background-size: 9px 9px, 13px 13px;
    background-position: 0 0, 4px 6px;
    box-shadow: inset 0 0 30px rgba(60, 30, 10, 0.35), 0 14px 34px rgba(43, 16, 18, 0.12);
}

/*
    Phones, admin Arrange board: keeps its shape at a readable size and scrolls sideways.
    Phones, public board (.cork-fit): shrinks to the screen width instead. Everything inside is
    sized in cqw only (no px floors), so it looks exactly like the 760px board, just smaller;
    a tap opens a note or painting full size (js/wip-board.js, .board-zoom below).
*/
@media (max-width: 699px) {
    .cork-board {
        width: 760px;
        border-width: 10px;
    }

    .cork-board.cork-fit {
        width: 100%;
        border-width: 7px;
        border-radius: 16px;
    }

    /* The px floors of the big board, turned into cqw of a 760px board (e.g. 11px = 1.45cqw). */
    .cork-fit .board-painting::before,
    .cork-fit .board-note::before {
        min-width: 0;
        min-height: 0;
        width: 1.6cqw;
        height: 1.6cqw;
        margin-left: -0.8cqw;
    }

    .cork-fit .board-painting figcaption { font-size: 1.85cqw; }
    .cork-fit .board-note-text { font-size: 1.45cqw; }
    .cork-fit .board-note-by { font-size: 1.85cqw; }
    .cork-fit .board-note-waiting { font-size: 1.3cqw; }

    .cork-fit .board-note.is-waiting,
    .cork-fit .board-note.is-draft {
        outline-width: 2px;
        outline-offset: 2px;
    }

    .cork-fit .board-painting:not(.is-draft),
    .cork-fit .board-note:not(.is-draft) {
        cursor: zoom-in;
    }
}

/* ---------- Tap to enlarge (phones, public board) ---------- */

.board-zoom {
    width: min(88vw, 360px);
    max-height: 92vh;
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
}

.board-zoom::backdrop {
    background: rgba(43, 16, 18, 0.72);
}

.board-zoom-stage {
    container-type: inline-size;
    padding: 1.4rem 0.6rem 0.8rem;
}

/* The copy of the tapped item, shown big and in normal flow. */
.board-zoom-stage .board-note,
.board-zoom-stage .board-painting {
    position: relative;
    left: auto !important;
    top: auto !important;
    width: 100%;
    transform: rotate(var(--tilt, 0deg));
    animation: none;
    outline: 0;
}

.board-zoom-stage .board-note {
    min-height: 0;
    aspect-ratio: 1;
    padding: 9cqw 7cqw 6cqw;
}

.board-zoom-stage .board-note-text { font-size: 7cqw; }
.board-zoom-stage .board-note-by { font-size: 9cqw; margin-top: 3cqw; }
.board-zoom-stage .board-painting { padding: 4cqw 4cqw 0; }
.board-zoom-stage .board-painting figcaption { font-size: 9cqw; padding: 2cqw 0 3cqw; }

.board-zoom-stage .board-note-waiting {
    bottom: -5cqw;
    padding: 1cqw 4cqw;
    font-size: 4cqw;
}

.board-zoom-close {
    display: block;
    min-height: 44px;
    margin: 1.4rem auto 0;
    padding: 0.5rem 1.6rem;
    border: 2px solid #F8DDE2;
    border-radius: 999px;
    background: transparent;
    color: #F8DDE2;
    font-family: "Rubik", system-ui, sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
}

.board-hint {
    display: none;
}

@media (max-width: 699px) {
    .board-hint {
        display: block;
        margin: 0.5rem 0 0;
        font-size: 0.85rem;
        color: #7B5458;
        text-align: center;
    }
}

/* Push pin shared by paintings and notes. */
.board-painting::before,
.board-note::before {
    content: "";
    position: absolute;
    top: -0.7cqw;
    left: 50%;
    z-index: 2;
    width: 1.5cqw;
    height: 1.5cqw;
    min-width: 12px;
    min-height: 12px;
    margin-left: -0.75cqw;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #B04A58, #5A1E26 70%);
    box-shadow: 0 3px 4px rgba(0, 0, 0, 0.35);
}

/* ---------- Pinned paintings ---------- */

.board-painting {
    position: absolute;
    width: calc(var(--size, 26) * 1cqw);
    margin: 0;
    padding: 0.8cqw 0.8cqw 0;
    background: #FBF6F0;
    box-shadow: 0 8px 18px rgba(40, 20, 5, 0.35);
    transform: translate(-50%, -50%) rotate(var(--tilt, 0deg));
}

.board-painting img {
    display: block;
    width: 100%;
    height: auto;
}

.board-painting figcaption {
    padding: 0.5cqw 0 0.7cqw;
    font-family: "Pinyon Script", cursive;
    font-size: max(14px, 2.1cqw);
    line-height: 1.1;
    color: #5A1E26;
    text-align: center;
}

/* ---------- Sticky notes ---------- */

.board-note {
    position: absolute;
    width: 15cqw;
    min-height: 15cqw;
    padding: 1.4cqw 1.1cqw 1cqw;
    box-shadow: 0 6px 12px rgba(40, 20, 5, 0.3);
    color: #2B1012;
    font-family: "DM Sans", system-ui, sans-serif;
    transform: translate(-50%, -50%) rotate(var(--tilt, 0deg));
}

.paper-cream {
    background: #FFFBEF;
}

.paper-blush {
    background: #F8DDE2;
}

.paper-butter {
    background: #F6EBC8;
}

/* The drawing covers the whole note; typed words sit on top of it. */
.board-note-drawing {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.board-note-text {
    position: relative;
    margin: 0;
    font-size: max(11px, 1.35cqw);
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.board-note-by {
    position: relative;
    margin: 0.5cqw 0 0;
    font-family: "Pinyon Script", cursive;
    font-size: max(14px, 1.9cqw);
    line-height: 1;
    color: #5A1E26;
}

/* The visitor's own note before Hanna approves it, and a note being placed. */
.board-note.is-waiting,
.board-note.is-draft {
    outline: 3px dashed #5A1E26;
    outline-offset: 3px;
}

.board-note-waiting {
    position: absolute;
    left: 50%;
    bottom: -2.6cqw;
    padding: 0.2cqw 0.8cqw;
    border-radius: 999px;
    background: #5A1E26;
    color: #FBF6F0;
    font-size: max(10px, 0.95cqw);
    font-weight: 700;
    white-space: nowrap;
    transform: translateX(-50%);
}

/* Anything that can be dragged: no page scrolling under the finger, a grab cursor, a lift while held. */
.is-draft,
.board-arrange .board-note,
.board-arrange .board-painting {
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.is-draft:focus-visible,
.board-arrange .board-note:focus-visible,
.board-arrange .board-painting:focus-visible {
    outline: 3px solid #2B1012;
    outline-offset: 3px;
}

.is-dragging {
    cursor: grabbing;
    box-shadow: 0 16px 28px rgba(40, 20, 5, 0.4);
}

.is-draft {
    animation: draft-wiggle 1.6s ease-in-out 2;
}

@keyframes draft-wiggle {
    0%, 100% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)); }
    50% { transform: translate(-50%, -52%) rotate(calc(var(--tilt, 0deg) + 2deg)); }
}

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

/* ---------- The drawing pad on the note form ---------- */

.note-pad {
    position: relative;
    width: min(100%, 340px);
    aspect-ratio: 1;
    margin: 0 auto;
    box-shadow: 0 6px 14px rgba(40, 20, 5, 0.25);
    transform: rotate(-1deg);
}

.note-pad canvas,
.note-pad textarea {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.note-pad canvas {
    touch-action: none;
}

.note-pad textarea {
    padding: 1rem;
    border: 0;
    background: transparent;
    color: #2B1012;
    font: inherit;
    font-size: 1.15rem;
    line-height: 1.35;
    resize: none;
}

.note-pad textarea:focus {
    outline: none;
}

/* Typing: the text box is on top. Drawing: the canvas is on top, and the words show through. */
.note-pad.is-typing canvas {
    pointer-events: none;
}

.note-pad.is-drawing textarea {
    pointer-events: none;
}

.note-pad.is-drawing {
    cursor: crosshair;
}

.note-modes {
    display: inline-flex;
    justify-self: center;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
}

.note-modes button {
    min-width: 92px;
    min-height: 40px;
    padding: 0.3rem 1rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #5A1E26;
    font-family: "Rubik", system-ui, sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
}

.note-modes button[aria-pressed="true"] {
    background: #5A1E26;
    color: #FBF6F0;
}

.note-tools {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.7rem 1.4rem;
}

.swatches {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.swatch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 2px solid rgba(43, 16, 18, 0.25);
    border-radius: 50%;
    cursor: pointer;
}

.swatch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.swatch:has(input:checked) {
    border-color: #2B1012;
    box-shadow: 0 0 0 3px #FBF6F0, 0 0 0 5px #2B1012;
}

.swatch:has(input:focus-visible) {
    outline: 3px solid #74303A;
    outline-offset: 4px;
}

.swatch-cream {
    background: #FFFBEF;
}

.swatch-blush {
    background: #F8DDE2;
}

.swatch-butter {
    background: #F6EBC8;
}

.swatch.pen {
    width: 28px;
    height: 28px;
}

/* Pen colors (the radio values hold the same colors for the drawing itself). */
.pen-1 { background: #5A1E26; }
.pen-2 { background: #2B2B2B; }
.pen-3 { background: #2F5D8A; }
.pen-4 { background: #3E7A4A; }
.pen-5 { background: #D9822B; }
