/* The Reset: the whole page is a cork board in a wooden frame.
   Cards are pinned to it, red string runs between the pins (script.js),
   and each card opens as a case file in a dialog. */

:root {
    color-scheme: dark; /* a wall is the same in light mode */
}

body {
    --bg: #2a1c10;
    --bg-art: none;
    --cork: #b07d4f;
    --wood: #5a3d28;
    --paper: #f4ecd4;
    --ink: #2a2418;
    --string: #c0342b;
    --link: #0b5a47;

    min-height: 100dvh;
    color: var(--ink);
    background-color: var(--cork);
    background-image:
        radial-gradient(ellipse at 50% 30%, transparent 40%, rgba(40, 20, 5, 0.5)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' seed='6'/%3E%3CfeColorMatrix values='0 0 0 0 .32  0 0 0 0 .2  0 0 0 0 .08  0 0 0 .75 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-attachment: fixed, scroll;
}

/* The frame, fixed around the window */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    border: 12px solid var(--wood);
    box-shadow:
        inset 0 0 0 2px #3b2716,
        inset 6px 6px 14px rgba(0, 0, 0, 0.45);
}

/* ---- the board ---- */

.board {
    width: min(100% - 5rem, 72rem);
    margin: 0 auto;
    padding-bottom: 5rem;
}

.board-head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 1rem;
    padding: 2.2rem 0 3rem;
}

.head-main {
    display: grid;
    justify-items: center;
    gap: 0.9rem;
    text-align: center;
}

.tape-small,
.tape,
.back-tag {
    font: 700 0.8rem/1.2 var(--mono);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #fff;
    background: #14100c;
}

.tape-small,
.tape {
    padding: 0.3rem 0.9rem;
    box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.4);
}

/* The way back: a strip of label tape stuck in the corner */
.back-tag {
    justify-self: start;
    padding: 0.45rem 0.8rem;
    text-decoration: none;
    box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.4);
    transform: rotate(-2deg);
}

.back-tag::before {
    content: "\25C2";
    margin-right: 0.6em;
}

.back-tag:hover {
    color: #14100c;
    background: #ffe27a;
}

.back-tag:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* The counts: a small card pinned in the other corner */
.tally {
    position: relative;
    justify-self: end;
    min-width: 8rem;
    padding: 1.1rem 1rem 0.7rem;
    background: var(--paper);
    box-shadow: 3px 5px 8px rgba(0, 0, 0, 0.35);
    transform: rotate(1.6deg);
}

.tally dl > div {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    font: 700 0.8rem/1.7 var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tally dd {
    color: var(--string);
}

.tally .pin {
    --pin: #2f6fd0;
}

.tape-small {
    transform: rotate(-2deg);
}

.tape {
    font-size: clamp(1.6rem, 6vw, 3rem);
    letter-spacing: 0.2em;
    transform: rotate(0.8deg);
}

.question {
    max-width: 24rem;
    padding: 0.6rem 1.1rem;
    font-size: 1.15rem;
    font-weight: 600;
    background: var(--paper);
    box-shadow: 3px 5px 8px rgba(0, 0, 0, 0.35);
    transform: rotate(-1.2deg);
}

.board-area {
    position: relative;
}

.strings {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.strings path {
    fill: none;
    stroke: var(--string);
    stroke-width: 2.5;
    stroke-linecap: round;
    filter: drop-shadow(1px 2px 1px rgba(0, 0, 0, 0.5));
}

.strings path.loose {
    stroke-dasharray: 2 8;
}

.cards {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 3.5rem 2.5rem;
    list-style: none;
}

.card-slot:nth-child(4n + 2) {
    margin-top: 1.4rem;
}

.card-slot:nth-child(4n + 4) {
    margin-top: 0.7rem;
}

.target-slot {
    grid-column: 1 / -1;
    margin-top: 1rem !important;
}

/* ---- cards ---- */

.card {
    --tilt: -1.6deg;
    --pin: #d63c32;

    position: relative;
    display: block;
    width: 100%;
    min-height: 9.5rem;
    padding: 1.5rem 1rem 2.4rem;
    font: inherit;
    text-align: left;
    color: var(--ink);
    background: var(--paper);
    background-image: repeating-linear-gradient(to bottom, transparent 0 1.55rem, rgba(60, 90, 160, 0.16) 1.55rem calc(1.55rem + 1px));
    border: 1px solid #c9bc97;
    box-shadow:
        1px 1px 0 rgba(0, 0, 0, 0.12),
        4px 6px 8px rgba(0, 0, 0, 0.35);
    transform: rotate(var(--tilt));
    transition: box-shadow 0.15s;
}

button.card {
    cursor: pointer;
}

button.card:hover {
    box-shadow:
        1px 1px 0 rgba(0, 0, 0, 0.12),
        6px 12px 14px rgba(0, 0, 0, 0.4);
}

button.card:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 4px;
}

.card > span {
    display: block;
}

.card-slot:nth-child(4n + 2) .card {
    --tilt: 1.2deg;
    --pin: #2f6fd0;
}

.card-slot:nth-child(4n + 3) .card {
    --tilt: -0.7deg;
    --pin: #e8b520;
}

.card-slot:nth-child(4n + 4) .card {
    --tilt: 2deg;
    --pin: #2c9a58;
}

.card-no {
    font: 700 0.75rem/1.4 var(--mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--string);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
}

.card-text {
    margin-top: 0.4rem;
    font-size: 0.95rem;
}

.pin {
    position: absolute;
    top: -0.55rem;
    left: 50%;
    width: 1.1rem;
    height: 1.1rem;
    margin-left: -0.55rem;
    background: radial-gradient(circle at 35% 30%, #fff8 0 12%, transparent 30%), var(--pin);
    border-radius: 50%;
    box-shadow:
        1px 3px 3px rgba(0, 0, 0, 0.5),
        inset -2px -2px 3px rgba(0, 0, 0, 0.3);
}

.stamp {
    --stamp: #a8321f;

    position: absolute;
    right: 0.7rem;
    bottom: 0.6rem;
    padding: 0.05rem 0.5rem;
    font: 700 0.8rem/1.5 var(--mono);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--stamp);
    border: 2px solid var(--stamp);
    border-radius: 3px;
    opacity: 0.85;
    transform: rotate(-7deg);
}

[data-status="wip"] .stamp,
.file-status[data-status="wip"] {
    --stamp: #1f55b0;
}

[data-status="completed"] .stamp,
.file-status[data-status="completed"] {
    --stamp: #1b7f4a;
}

[data-status="on-hold"] .stamp,
.file-status[data-status="on-hold"] {
    --stamp: #a86a00;
}

[data-status="abandoned"] .stamp,
.file-status[data-status="abandoned"] {
    --stamp: #6b6b6b;
}

.sticky {
    --paper: #ffe27a;

    background-image: none;
}

.ghost {
    color: #fff;
    background: rgba(244, 236, 212, 0.18);
    background-image: none;
    border: 2px dashed rgba(244, 236, 212, 0.7);
    box-shadow: none;
}

.ghost .card-no {
    color: #ffd9d5;
}

.target {
    border: 2px solid var(--string);
}

.target .card-title {
    font-size: 1.4rem;
}

.noscript {
    margin-top: 2rem;
    padding: 0.6rem 1rem;
    background: var(--paper);
}

/* ---- the case file ---- */

.file {
    width: min(38rem, 100% - 2.5rem);
    max-height: calc(100dvh - 3rem);
    margin: auto;
    padding: 0;
    overflow: visible;
    color: var(--ink);
    background: none;
    border: 0;
}

.file:modal {
    overscroll-behavior: contain;
}

.file::backdrop {
    overflow: hidden;
    overscroll-behavior: contain;
    background: rgba(15, 8, 2, 0.75);
}

.folder {
    position: relative;
    padding: 1.1rem 1rem 1rem;
    background: #dcc388;
    border: 2px solid #8c7438;
    border-radius: 3px 10px 3px 3px;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5);
}

.file-tab {
    position: absolute;
    top: -1.7rem;
    left: 1.2rem;
    padding: 0.35rem 1rem 0.2rem;
    font: 700 0.8rem/1.2 var(--mono);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    background: #dcc388;
    border: 2px solid #8c7438;
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
}

.file-close {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    font: 700 1.4rem/1 var(--mono);
    color: var(--ink);
    cursor: pointer;
    background: none;
    border: 0;
}

.file-close:hover {
    color: var(--string);
}

.file-close:focus-visible,
.file-nav button:focus-visible,
.file-link:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.file-heading {
    padding-right: 2rem;
    margin-bottom: 0.7rem;
    font-size: 1.4rem;
    line-height: 1.25;
}

.paper {
    max-height: calc(100dvh - 12rem);
    padding: 1rem 1.1rem 1.2rem;
    overflow-y: auto;
    background: var(--paper);
    box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.2);
}

.paper > * + * {
    margin-top: 0.75rem;
}

.paper a {
    color: var(--link);
}

.file-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1rem;
    font: 0.8rem/1.4 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.file-status {
    --stamp: #a8321f;

    padding: 0 0.5rem;
    font-weight: 700;
    color: var(--stamp);
    border: 2px solid var(--stamp);
    border-radius: 3px;
}

.level {
    display: flex;
    gap: 0.25rem;
}

.level i {
    width: 0.65rem;
    height: 0.65rem;
    border: 2px solid #6f674f;
    border-radius: 50%;
}

.level i.on {
    background: var(--string);
    border-color: var(--string);
}

.findings {
    padding: 0.6rem 0.8rem;
    background: rgba(255, 226, 122, 0.45);
    border-left: 4px solid #d6a400;
}

.findings strong {
    display: block;
    font: 700 0.75rem/1.4 var(--mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.facts > div {
    display: flex;
    gap: 1rem;
    padding-block: 0.3rem;
    border-top: 1px dashed #b3a77f;
}

.facts dt {
    flex: none;
    width: 6.5rem;
    font: 700 0.8rem/1.6 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--string);
}

.file-link {
    display: inline-block;
    padding: 0.25rem 0.9rem;
    font-weight: 700;
    color: var(--paper);
    text-decoration: none;
    background: var(--ink);
    border-radius: 3px;
}

.paper a.file-link {
    color: var(--paper);
}

.file-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 0.8rem;
}

.file-nav button {
    padding: 0.3rem 0.8rem;
    font: 700 0.8rem/1.4 var(--mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink);
    cursor: pointer;
    background: none;
    border: 2px solid var(--ink);
    border-radius: 3px;
}

.file-nav button:hover:not(:disabled) {
    color: #dcc388;
    background: var(--ink);
}

.file-nav button:disabled {
    visibility: hidden;
}

@media (prefers-reduced-motion: no-preference) {
    .file[open] {
        animation: file-open 0.22s ease-out;
    }
}

@keyframes file-open {
    from {
        opacity: 0;
        transform: translateY(1rem) rotate(-1.5deg) scale(0.97);
    }
}

@media (max-width: 44rem) {
    body::after {
        border-width: 6px;
    }

    .board {
        width: calc(100% - 2.5rem);
    }

    .board-head {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        padding-top: 1.6rem;
    }

    .board-head > * {
        justify-self: center;
    }

    .back-tag {
        justify-self: start;
    }

    .tally {
        order: 3;
    }

    .cards {
        grid-template-columns: minmax(0, 1fr);
    }

    .card-slot:nth-child(n) {
        margin-top: 0;
    }
}
