/* ==========================================================================
   Clipboard
   A wooden board with a sheet of ruled paper clamped to it and a pen lying
   across the bottom (client/partials/molecules/clipboard.js). On the
   dashboard it is the middle column and carries the checklist as a
   handwritten todo list (client/partials/molecules/todoList.js).

   Board, paper and the three pens are the same in both colour modes — the
   clipboard is a drawn object, not an app surface. The colours are tokens in
   base.css beside --app-black-rgb for exactly that reason.
   ========================================================================== */

.clipboard {
    --clipboard-rule: 27px;
    --clipboard-line: rgba(var(--clipboard-ink-rgb), 0.22);
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    padding: 26px 14px 52px;
    border-radius: 12px;
    text-align: left;
    background-color: var(--clipboard-board);
    background-image:
        linear-gradient(158deg, rgba(var(--app-white-rgb), 0.2), rgba(var(--app-black-rgb), 0.08) 55%, rgba(var(--app-black-rgb), 0.3)),
        repeating-linear-gradient(93deg, rgba(var(--app-black-rgb), 0.05) 0 3px, rgba(var(--app-white-rgb), 0.05) 3px 8px);
    box-shadow:
        0 14px 28px rgba(var(--app-black-rgb), 0.45),
        0 3px 6px rgba(var(--app-black-rgb), 0.3),
        /* Die Staerke des Bretts: eine dunkle Kante unten, eine helle oben —
           dasselbe Licht, das den Verlauf darueber zeichnet. */
        inset 0 -6px 0 rgba(var(--app-black-rgb), 0.22),
        inset 0 2px 0 rgba(var(--app-white-rgb), 0.22),
        inset 0 0 0 2px rgba(var(--app-black-rgb), 0.16);
    /* Das Brett liegt auf der Seite, leicht von der Seite gesehen. Die Winkel
       sind klein mit Absicht: ein Grad mehr und die Handschrift darauf
       franst aus. `preserve-3d` ist die Haelfte der Wirkung — erst damit
       stehen Klammer, Blatt und Stift wirklich ueber dem Brett statt darauf
       gedruckt zu sein. */
    transform: perspective(700px) rotateX(3deg) rotateY(-6deg);
    transform-style: preserve-3d;
}

/* The clamp overlaps the top of the sheet, exactly as the real thing does. */
.clipboard__clip {
    position: absolute;
    top: 2px;
    left: 50%;
    width: 104px;
    transform: translateX(-50%) translateZ(14px);
    z-index: 3;
    pointer-events: none;
    filter: drop-shadow(0 2px 3px rgba(var(--app-black-rgb), 0.35));
}

/* Decoration only — never swallows a click meant for a line. */
.clipboard__pen {
    position: absolute;
    right: 12px;
    bottom: 28px;
    width: 148px;
    z-index: 2;
    pointer-events: none;
    transform: rotate(-5deg) translateZ(10px);
    transform-origin: 100% 50%;
    filter: drop-shadow(0 3px 4px rgba(var(--app-black-rgb), 0.4));
}

.clipboard__paper {
    position: relative;
    z-index: 1;
    /* Top padding clears the clamp, bottom padding clears the pen. */
    padding: 32px 16px 20px;
    transform: translateZ(6px);
    border-radius: 2px 2px 5px 5px;
    background-color: var(--clipboard-paper);
    color: var(--clipboard-ink);
    box-shadow: 0 5px 14px rgba(var(--app-black-rgb), 0.4);
}

/* A torn-off look along the bottom edge of the sheet. */
.clipboard__paper::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 6px;
    border-radius: 0 0 5px 5px;
    background: linear-gradient(to bottom, rgba(var(--clipboard-ink-rgb), 0), rgba(var(--clipboard-ink-rgb), 0.12));
}

/* The first line of the sheet: the title, and the way into the page it
   summarises on the right — the same arrangement as the head of the two
   column cards beside it. */
.clipboard__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--clipboard-line);
}

.clipboard__title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--app-font-hand);
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--clipboard-ink);
}

.clipboard__action {
    position: relative;
    flex: 0 0 auto;
    line-height: 1;
}

/* The corner button sits on paper, not on an app surface, so it takes the ink
   of the sheet rather than the theme's — otherwise the dark mode writes it in
   a light grey on cream. Through Bootstrap's own variables, and on the button
   itself: `.btn-link` declares --bs-btn-color on the element, which beats the
   same variable inherited from the parent. */
.clipboard__action .btn-link {
    --bs-btn-color: var(--clipboard-ink-faded);
    --bs-btn-hover-color: var(--clipboard-ink);
    --bs-btn-active-color: var(--clipboard-ink);
}

/* ==========================================================================
   The todo list on the paper
   ========================================================================== */

/* One ruling per line box: a line that wraps lands on a rule just like a
   short one, which is why the period and the line-height are one token. */
.clipboard__list {
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: var(--app-font-hand);
    font-size: 1.15rem;
    line-height: var(--clipboard-rule);
    background-image: linear-gradient(to bottom, transparent calc(100% - 1px), var(--clipboard-line) calc(100% - 1px));
    background-size: 100% var(--clipboard-rule);
    background-repeat: repeat-y;
}

.todo-item {
    margin: 0;
}

/* `.todo-item >` and not a bare class: `a:link` in utilities.css lays every
   link out as an inline-block and wins on specificity otherwise, which sizes
   a linked line by font metrics instead of by the line-height and walks the
   rulings off the text. */
.todo-item > .todo-item__line {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-decoration: none;
    border-bottom: none;
    color: inherit;
}

a.todo-item__line:hover .todo-item__text {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.todo-item__box {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    /* Centres the box on the first line of the row; Caveat sits low in its
       line box, so the box goes a notch below the geometric centre. */
    margin-top: calc(((var(--clipboard-rule) - 18px) / 2) + 2px);
}

.todo-item__text {
    flex: 1 1 auto;
    min-width: 0;
}

/* Every line is rendered; the "show all" line only takes the cover off. */
.todo-item--hidden {
    display: none;
}

/* Still to do — written and boxed in red pen. */
.todo-item--open {
    color: var(--clipboard-pen-red);
}

/* Done — ticked in green, the line struck through and faded. */
.todo-item--done {
    color: var(--clipboard-pen-green);
}

.todo-item--done .todo-item__text {
    color: var(--clipboard-ink-faded);
    text-decoration: line-through;
    text-decoration-thickness: 2px;
    text-decoration-color: rgba(var(--clipboard-ink-rgb), 0.45);
}

.todo-item--more {
    cursor: pointer;
    color: var(--clipboard-ink);
}

.todo-item--more .todo-item__text {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

@media screen and (max-width: 575px) {
    .clipboard {
        padding-left: 10px;
        padding-right: 10px;
        /* Nur noch die Neigung nach hinten: das Brett steht hier fast in der
           vollen Breite, und das seitliche Drehen schiebt die nahe Kante ueber
           den Rand des Bildschirms. */
        transform: perspective(900px) rotateX(1.2deg);
    }

    .clipboard__paper {
        padding-left: 12px;
        padding-right: 12px;
    }

    .clipboard__pen {
        width: 118px;
    }
}
