/* Field Notes: the page's own styles, on top of the --cl-* tokens. */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--cl-bg);
    color: var(--cl-text-body);
    font-family: var(--cl-sans);
    font-size: 16px;
    line-height: 1.6;
}

/* Room for the notch and the home bar once it's on the home screen. */
main {
    max-width: 680px;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top) + var(--cl-space-4)) calc(env(safe-area-inset-right) + var(--cl-space-3)) calc(env(safe-area-inset-bottom) + 48px) calc(env(safe-area-inset-left) + var(--cl-space-3));
}

[hidden] { display: none !important; }

a { color: var(--cl-accent); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--cl-space-3);
    min-height: 40px;
    margin-bottom: var(--cl-space-4);
    font-family: var(--cl-mono);
    font-size: 13px;
}

.wordmark {
    color: var(--cl-text-muted);
    text-decoration: none;
}

.wordmark:hover { color: var(--cl-accent); }

h1 {
    margin: 0 0 var(--cl-space-2);
    font-family: var(--cl-mono);
    font-size: 30px;
    font-weight: 700;
    color: var(--cl-text-bright);
}

h1 span { color: var(--cl-accent); }

.lede {
    margin: 0 0 var(--cl-space-5);
    color: var(--cl-text-soft);
}

/* The site's two buttons (.btn-cl and .btn-cl-primary), plus a quiet
   text button for the housekeeping links. */
.btn {
    display: inline-block;
    font-family: var(--cl-mono);
    font-weight: 700;
    font-size: 14px;
    padding: 12px var(--cl-space-4);
    border: 2px solid var(--cl-accent);
    border-radius: var(--cl-radius);
    background: var(--cl-surface-alt);
    color: var(--cl-accent);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn:hover:not(:disabled) {
    background: var(--cl-accent);
    color: var(--cl-surface-alt);
}

.btn-primary {
    background: var(--cl-accent);
    color: var(--cl-surface-alt);
}

.btn-primary:hover:not(:disabled) {
    background: var(--cl-accent-dim);
    border-color: var(--cl-accent-dim);
}

.btn:disabled { opacity: 0.6; cursor: progress; }

.btn-wide { width: 100%; }

.link-btn {
    padding: var(--cl-space-2) 0;
    font-family: var(--cl-mono);
    font-size: 13px;
    color: var(--cl-text-muted);
    background: none;
    border: 0;
    cursor: pointer;
}

.link-btn:hover { color: var(--cl-accent); }

/* ===== Mining =====
   The log of tiles coming up out of the wiki while the case is built. */
.mine-log {
    margin: var(--cl-space-3) 0 0;
    padding: var(--cl-space-3);
    list-style: none;
    font-family: var(--cl-mono);
    font-size: 13px;
    color: var(--cl-text-soft);
    background: var(--cl-surface-alt);
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
}

.mine-log li { overflow-wrap: anywhere; }

.mine-log li::before { content: '> '; color: var(--cl-accent); }

.mine-log .is-working::after {
    content: '_';
    color: var(--cl-accent);
    animation: blink 1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ===== Case list ===== */
.section-label {
    margin: var(--cl-space-5) 0 var(--cl-space-2);
    font-family: var(--cl-mono);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cl-text-muted);
}

label.section-label { display: block; }

.case-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.case-list a {
    display: block;
    padding: 14px var(--cl-space-3);
    margin-bottom: var(--cl-space-2);
    text-decoration: none;
    background: var(--cl-surface);
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius-card);
}

.case-list a:hover { border-color: var(--cl-accent); }

.case-list strong {
    display: block;
    font-family: var(--cl-mono);
    font-size: 15px;
    color: var(--cl-text-bright);
    overflow-wrap: anywhere;
}

.case-list small,
.empty,
.fine-print {
    font-family: var(--cl-mono);
    font-size: 12px;
    color: var(--cl-text-muted);
}

.empty { margin: 0; }

.tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--cl-space-4);
    margin-top: var(--cl-space-3);
}

.fine-print { margin: var(--cl-space-2) 0 0; }

.tags-hint code {
    font-family: inherit;
    color: var(--cl-text-soft);
}

.notice {
    margin: var(--cl-space-3) 0 0;
    font-family: var(--cl-mono);
    font-size: 13px;
    color: var(--cl-text-soft);
}

/* ===== Case file =====
   The same dossier One Block opens: mono labels, sans scenes, an accent
   rubber stamp. */
.case-file {
    padding: var(--cl-space-4) var(--cl-space-3);
    background: var(--cl-surface-alt);
    border: 1px dashed var(--cl-border);
    border-radius: var(--cl-radius);
}

.case-stamp {
    display: inline-block;
    margin-bottom: 12px;
    padding: 2px 10px;
    font-family: var(--cl-mono);
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.18em;
    color: var(--cl-accent);
    border: 2px solid var(--cl-accent);
    border-radius: var(--cl-radius);
    transform: rotate(-4deg);
    opacity: 0.85;
}

.case-operation {
    margin: 0 0 var(--cl-space-3);
    font-family: var(--cl-mono);
    font-size: 19px;
    line-height: 1.35;
    color: var(--cl-text-bright);
    overflow-wrap: anywhere;
}

.case-hook,
.case-scene,
.case-critter p,
.case-theory {
    margin: 0 0 var(--cl-space-3);
    font-size: 16px;
    line-height: 1.65;
    color: var(--cl-text-body);
}

.case-hook { font-style: italic; }

#caseExcuse { margin: 0 0 var(--cl-space-3); }

.case-part-title {
    margin: var(--cl-space-4) 0 var(--cl-space-2);
    font-family: var(--cl-mono);
    font-size: 14px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cl-accent);
}

.case-clues {
    margin: 0;
    padding-left: 20px;
    font-family: var(--cl-mono);
    font-size: 13px;
    color: var(--cl-text-soft);
}

.case-clues li { margin-bottom: var(--cl-space-1); }

.case-critter {
    margin-bottom: 12px;
    padding: 12px 14px;
    background: var(--cl-surface);
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
}

.case-critter-name {
    font-family: var(--cl-mono);
    color: var(--cl-text-bright);
}

.case-critter p { margin: var(--cl-space-1) 0 0; }

.case-critter .case-weakness {
    font-family: var(--cl-mono);
    font-size: 13px;
    margin-top: var(--cl-space-2);
}

/* A black bar until tapped. */
.case-redacted {
    padding: 0 4px;
    font: inherit;
    color: var(--cl-text-muted);
    background: var(--cl-text-muted);
    border: 0;
    border-radius: 2px;
    cursor: pointer;
    text-align: left;
}

.case-redacted:focus-visible { outline: 1px solid var(--cl-accent); }

.case-redacted.is-declassified {
    padding: 0;
    color: var(--cl-text-body);
    background: none;
    cursor: default;
}

.reveal { margin-top: var(--cl-space-2); }
.reveal[hidden] { display: none; }

.mine-panel { margin-bottom: var(--cl-space-4); }
.mine-panel .empty { margin-bottom: var(--cl-space-2); }

/* ===== The board =====
   A pinboard of the mined pages: paper cards, slightly askew, joined by
   red string. The string and pins are artwork, the one colour here
   outside the tokens, as on One Block: a conspiracy board's string is red
   (AGENTS.md: game and artwork colours are content). */
.board {
    --string: #c62f2f;
    position: relative;
    margin-bottom: var(--cl-space-4);
    padding: var(--cl-space-3) var(--cl-space-3) var(--cl-space-4);
    background-color: var(--cl-surface);
    background-image: radial-gradient(color-mix(in srgb, var(--cl-border) 70%, transparent) 1px, transparent 1px);
    background-size: 14px 14px;
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
}

.board-codename {
    margin: 0 0 var(--cl-space-3);
    font-family: var(--cl-mono);
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--cl-text-muted);
}

.board-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: var(--cl-space-4) var(--cl-space-3);
}

.board-card {
    position: relative;
    z-index: 1;
    display: block;
    padding: 12px 6px 8px;
    font-family: var(--cl-mono);
    font-size: 11px;
    line-height: 1.3;
    text-decoration: none;
    color: var(--cl-surface-alt);
    background: var(--cl-text-bright);
    border-radius: 2px;
    box-shadow: var(--cl-shadow-card);
    transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--tilt, 0deg));
    transition: transform 0.2s ease;
}

/* Phones keep a tapped card in :hover after you come back from Wikipedia,
   so the straighten-up is for real pointers and the keyboard only. */
.board-card:focus-visible {
    transform: translate(var(--dx, 0), var(--dy, 0)) rotate(0deg) scale(1.04);
    outline: 2px solid var(--cl-accent);
    outline-offset: 2px;
}

@media (hover: hover) {
    .board-card:hover {
        transform: translate(var(--dx, 0), var(--dy, 0)) rotate(0deg) scale(1.04);
        outline: 2px solid var(--cl-accent);
        outline-offset: 2px;
    }
}

.board-card img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    margin-bottom: 6px;
    object-fit: cover;
    filter: grayscale(0.35) contrast(1.05);
}

/* Pencilled in the corner, for [link 2 5]. */
.board-card-number {
    position: absolute;
    top: 1px;
    left: 4px;
    font-size: 9px;
    font-weight: 700;
    color: var(--cl-text-muted);
}

.board-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.board-string {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: visible;
    pointer-events: none;
}

.board-thread {
    fill: none;
    stroke: var(--string);
    stroke-width: 2.5;
    stroke-linecap: round;
    filter: drop-shadow(0 2px 2px color-mix(in srgb, var(--cl-surface-alt) 80%, transparent));
}

.board-thread.is-drawing { animation: stringDraw 0.5s ease-out forwards; }

@keyframes stringDraw { to { stroke-dashoffset: 0; } }

.board-pin {
    fill: var(--string);
    stroke: var(--cl-text-bright);
    stroke-width: 1.5;
}

/* Why these two are linked, on an index card hung from the string. Taps
   go through to the photo cards underneath. */
.board-reason {
    position: absolute;
    z-index: 3;
    max-width: 120px;
    padding: 2px 6px;
    font-family: var(--cl-mono);
    font-size: 10px;
    line-height: 1.3;
    text-align: center;
    color: var(--cl-surface-alt);
    background: var(--cl-text-body);
    border-radius: 2px;
    box-shadow: var(--cl-shadow-card);
    pointer-events: none;
    transform: translate(-50%, -50%) rotate(var(--tilt, 0deg));
}

.board-reason.is-pinning {
    opacity: 0;
    animation: reasonPin 0.3s ease-out forwards;
}

@keyframes reasonPin {
    from { opacity: 0; transform: translate(-50%, -70%) rotate(var(--tilt, 0deg)); }
    to { opacity: 1; transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)); }
}

@media (prefers-reduced-motion: reduce) {
    .board-thread.is-drawing { animation: none; stroke-dashoffset: 0 !important; }
    .board-reason.is-pinning { animation: none; opacity: 1; }
    .board-card { transition: none; }
}

/* ===== Notebook =====
   Sans for what you wrote, mono for when you wrote it. */
.entries {
    margin: 0;
    padding: 0;
    list-style: none;
}

.entry {
    padding: 12px 0 var(--cl-space-3);
    border-bottom: 1px solid var(--cl-border);
}

.entry-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--cl-space-2);
}

.entry time {
    font-family: var(--cl-mono);
    font-size: 12px;
    color: var(--cl-accent-dim);
}

.entry-actions { display: flex; gap: var(--cl-space-3); }

.entry-actions .link-btn { padding: 0; font-size: 12px; }

.entry-text {
    margin: var(--cl-space-1) 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--cl-text);
}

/* 16px or iOS zooms the page every time you start writing. */
textarea {
    display: block;
    width: 100%;
    min-height: 120px;
    margin: var(--cl-space-3) 0 var(--cl-space-2);
    padding: 12px;
    font-family: var(--cl-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--cl-text);
    background: var(--cl-surface);
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--cl-accent);
}

.entry textarea { margin-top: var(--cl-space-2); }

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--cl-space-2) var(--cl-space-3);
}
