/*
 * Look and feel for every page.
 * Change the tokens in :root to restyle the site.
 * views/layout.php draws the nav, the marketing hero, and the content card.
 */

:root {
    color-scheme: dark;
    --bg: #0e0e10;
    --line: #1c1c20;
    --ink: #f4f4f6;
    --muted: #a8a8b0;
    --nav: #c8c8cc;
    --faint: #6e6e76;
    --cta: #246a8c;
    --cta-hover: #2f84a8;
    --secondary: #1a1a22;
    --secondary-line: #2a2a34;
    --card: #141418;
    --danger: #ff9b9b;
    --font: Inter, "IBM Plex Sans", sans-serif;
    --card-width: 480px;
    --radius: 12px;
    --control-radius: 9px;
}

@font-face {
    font-family: "Inter";
    src: url("/fonts/inter-latin.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("/fonts/inter-italic-latin.woff2") format("woff2");
    font-weight: 100 900;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: "Caveat";
    src: url("/fonts/caveat-latin.woff2") format("woff2");
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    letter-spacing: 0;
    line-height: 1.45;
}

.m-bar {
    display: flex;
    align-items: center;
    gap: 28px;
    min-height: 64px;
    padding: 0 28px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.m-wordmark {
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0;
    text-decoration: none;
    white-space: nowrap;
}

.site-nav {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    gap: 22px;
    margin: 0;
    color: var(--nav);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-align: left;
}

.m-links,
.m-end {
    display: flex;
    align-items: center;
    gap: 22px;
}

.m-end {
    margin-left: auto;
    gap: 18px;
}

.site-nav a,
.site-nav button {
    color: var(--nav);
    text-decoration: none;
}

.site-nav a:hover,
.site-nav button:hover {
    color: #ffffff;
}

.logout-form {
    display: flex;
    margin: 0;
}

.logout-form button {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.m-cta {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--control-radius);
    background: var(--cta);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.m-cta:hover {
    background: var(--cta-hover);
    color: #ffffff;
}

body.apps-page,
body.apps-page .m-bar {
    background: #12151a;
}

body.apps-page .m-bar {
    border-bottom-color: transparent;
}

.stage {
    flex: 1;
    padding: 28px 28px 72px;
}

.app-board {
    width: 100%;
    max-width: 920px;
}

.app-board .notice {
    margin: 0 0 14px;
    color: #8a96a0;
    font-family: Inter, "IBM Plex Sans", sans-serif;
    font-size: 15px;
    font-style: italic;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.45;
}

h1.app-board-title {
    margin: 0;
    color: #8a96a0;
    font-family: Inter, "IBM Plex Sans", sans-serif;
    font-size: 15px;
    font-style: italic;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.4;
    text-transform: none;
}

.app-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 14px;
}

.app-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 176px;
    padding: 19px;
    background: #1a1e24;
    border: 1px solid #2c343c;
    border-radius: 16px;
    box-shadow: none;
}

.app-tile-hit {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}

.app-tile-index {
    color: #8a96a0;
    font-family: Caveat, cursive;
    font-size: 52px;
    font-style: normal;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1;
    opacity: 0.85;
}

.app-tile-name {
    margin: auto 0 0;
    color: #e8eef2;
    font-family: Inter, "IBM Plex Sans", sans-serif;
    font-size: 21px;
    font-style: normal;
    font-weight: 650;
    letter-spacing: 0;
    line-height: 1.2;
}

.app-tile-note {
    margin: 4px 0 0;
    color: #8a96a0;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
}

.app-tile-go {
    position: relative;
    z-index: 2;
    align-self: flex-start;
    margin-top: 12px;
    color: #7ab0d0;
    font-family: Inter, "IBM Plex Sans", sans-serif;
    font-size: 14px;
    font-style: italic;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.2;
    text-decoration: none;
}

.app-tile:hover .app-tile-go,
.app-tile-go:hover {
    color: #b7d7ea;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.app-tile-go.is-closed {
    color: #8a96a0;
    font-style: normal;
    font-weight: 400;
    text-decoration: none;
}

.board {
    --grid: 24px;
    position: relative;
    flex: 1;
    min-height: 0;
    background-color: var(--bg);
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: var(--grid) var(--grid);
    overflow: hidden;
    cursor: text;
    touch-action: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.note,
.note-editor {
    position: absolute;
    margin: 0;
    color: var(--ink);
    font: 16px/1.35 var(--font);
}

.note {
    width: max-content;
    max-width: none;
    padding: 0;
    white-space: pre;
    cursor: grab;
    user-select: none;
}

.note.is-editing {
    visibility: hidden;
}

.note.is-dragging {
    cursor: grabbing;
}

.note.is-selected {
    box-shadow: 0 0 0 1px #7ab0d0;
}

.selection-box {
    position: absolute;
    z-index: 4;
    box-sizing: border-box;
    border: 1px solid #7ab0d0;
    background: rgba(36, 106, 140, 0.18);
    pointer-events: none;
}

.selection-box[hidden] {
    display: none !important;
}

.board.is-columns {
    display: grid;
    align-content: start;
    gap: 48px 32px;
    padding: 48px 40px 96px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    background-image: none;
    cursor: default;
}

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

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

.board.is-columns .note {
    position: relative;
    left: auto !important;
    top: auto !important;
    min-width: 0;
    width: auto;
    max-width: 100%;
    white-space: normal;
    cursor: pointer;
}

.board.is-columns .note-text {
    display: block;
    max-width: 100%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.board.is-columns .blur-toggle,
.board.is-columns .recycle-bin,
.board.is-columns .recycle-panel {
    position: fixed;
}

.board.is-blurred .note-text,
.board.is-blurred .note-editor textarea,
.board.is-blurred .recycle-list span {
    filter: blur(7px);
    user-select: none;
}

.note-text {
    white-space: pre;
}

.note-fuse {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 3px;
}

.note-fuse[hidden] {
    display: none !important;
}

.fuse-count {
    color: #ffcc70;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.04em;
    line-height: 1;
}

.fuse-row {
    display: flex;
    align-items: flex-end;
    gap: 3px;
}

.fuse-cord {
    position: relative;
    flex: 1 1 auto;
    height: 5px;
    margin-bottom: 6px;
    border-radius: 3px;
    background: repeating-linear-gradient(90deg, #e6c48a 0 5px, #a97840 5px 7px, #c49255 7px 11px);
    background-size: 18px 5px;
    animation: fuse-crawl 0.45s linear infinite;
}

.fuse-burned {
    position: absolute;
    left: 0;
    top: -1px;
    bottom: -1px;
    width: 0;
    border-radius: 3px;
    background: linear-gradient(90deg, #1a1612, #3a3026 80%, #ff6a1a);
}

.fuse-spark {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 9px;
    height: 14px;
    margin-left: -4px;
    border-radius: 50% 50% 42% 42%;
    background: radial-gradient(circle at 50% 72%, #fff6c8 0 22%, #ffb020 42%, #ff4d1a 68%, transparent 72%);
    filter: drop-shadow(0 0 5px #ff6a1a);
    animation: spark-flicker 0.16s steps(2, end) infinite;
}

.fuse-house {
    position: relative;
    flex: 0 0 auto;
    width: 26px;
    height: 22px;
}

.fuse-house svg {
    display: block;
    width: 26px;
    height: 20px;
}

.house-flames {
    position: absolute;
    left: 1px;
    right: 1px;
    bottom: 12px;
    display: none;
    align-items: flex-end;
    justify-content: center;
    height: 16px;
}

.house-flames span {
    width: 8px;
    height: 12px;
    margin: 0 -2px;
    border-radius: 50% 50% 40% 40%;
    background: radial-gradient(circle at 50% 80%, #fff6c8, #ffb020 36%, #ff3d14 70%);
    transform-origin: center bottom;
    animation: house-burn 0.28s ease-in-out infinite alternate;
}

.house-flames span:nth-child(2) {
    height: 16px;
    animation-duration: 0.2s;
}

.house-flames span:nth-child(3) {
    height: 11px;
    animation-duration: 0.34s;
    animation-delay: 0.08s;
}

.note-fuse.is-burning .fuse-count,
.note-fuse.is-burning .fuse-spark {
    display: none;
}

.note-fuse.is-burning .fuse-cord {
    animation: none;
}

.note-fuse.is-burning .fuse-burned {
    width: 100%;
    background: #2a241c;
}

.note-fuse.is-burning .house-flames {
    display: flex;
}

.note-fuse.is-burning .fuse-house svg {
    filter: brightness(1.15) sepia(0.35);
}

@keyframes fuse-crawl {
    from { background-position: 0 0; }
    to { background-position: 18px 0; }
}

@keyframes spark-flicker {
    from { transform: translateY(0) scale(1, 1); }
    to { transform: translateY(-2px) scale(1.12, 0.88); }
}

@keyframes house-burn {
    from { transform: scaleY(0.72); opacity: 0.75; }
    to { transform: scaleY(1.18); opacity: 1; }
}

.note-menu {
    position: absolute;
    left: 0;
    bottom: 100%;
    z-index: 3;
    display: none;
    align-items: flex-start;
    gap: 6px;
    padding-bottom: calc(var(--flame-height, 0px) + 8px);
}

.note:hover .note-menu,
.note:focus-within .note-menu {
    display: flex;
}

.note-due,
.note-delete,
.note-due-clear,
.note-due-input {
    box-sizing: border-box;
    height: 28px;
    border: 1px solid #7ab0d0;
    border-radius: 4px;
    background: var(--bg);
    color: var(--ink);
    font: 13px/1 var(--font);
}

.note-due {
    display: grid;
    place-items: center;
    width: 28px;
    padding: 0;
    color: #ff8a2a;
    cursor: pointer;
}

.note-due svg,
.note-delete svg {
    display: block;
    width: 16px;
    height: 16px;
}

.note-delete {
    display: grid;
    place-items: center;
    width: 28px;
    padding: 0;
    color: var(--danger);
    cursor: pointer;
}

.note-due:hover,
.note-delete:hover,
.note-due-clear:hover {
    border-color: #b7d7ea;
}

.note-due-fields {
    display: flex;
    align-items: center;
    gap: 4px;
}

.note-due-fields[hidden] {
    display: none !important;
}

.note-due-input {
    padding: 0 6px;
    color-scheme: dark;
}

.note-due-hour,
.note-due-minute {
    width: 52px;
    padding-right: 2px;
}

.note-due-clear {
    padding: 0 8px;
    border-color: #2c343c;
    color: var(--muted);
    cursor: pointer;
}

.blur-toggle,
.recycle-bin {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #7ab0d0;
    border-radius: 8px;
    background: var(--bg);
    color: var(--ink);
    cursor: pointer;
}

.blur-toggle {
    right: 64px;
}

.blur-toggle svg,
.recycle-bin svg {
    display: block;
    width: 18px;
    height: 18px;
}

.blur-toggle .blur-icon-show,
.board.is-blurred .blur-toggle .blur-icon-hide {
    display: none;
}

.board.is-blurred .blur-toggle .blur-icon-show {
    display: block;
}

.recycle-bin-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--cta);
    color: #fff;
    font: 11px/16px var(--font);
    text-align: center;
}

.recycle-bin-count[hidden],
.recycle-panel[hidden],
.recycle-empty[hidden] {
    display: none !important;
}

.recycle-panel {
    position: absolute;
    right: 16px;
    bottom: 64px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 280px;
    max-height: 320px;
    margin: 0;
    padding: 12px;
    overflow: auto;
    border: 1px solid var(--secondary-line);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
}

.recycle-empty {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.recycle-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.recycle-list li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.recycle-list span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
}

.recycle-restore {
    flex: 0 0 auto;
    height: 28px;
    padding: 0 8px;
    border: 1px solid #7ab0d0;
    border-radius: 4px;
    background: var(--bg);
    color: var(--ink);
    font: 13px/1 var(--font);
    cursor: pointer;
}

.note-editor {
    z-index: 2;
    width: max-content;
    min-width: 0;
    background: var(--bg);
    outline: 1px solid #7ab0d0;
}

.note-editor textarea {
    display: block;
    box-sizing: border-box;
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--bg);
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    line-height: inherit;
    white-space: pre;
    resize: none;
    outline: none;
    overflow: hidden;
}

.page {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 48px 24px 80px;
}

.card {
    width: 100%;
    max-width: var(--card-width);
    margin: 0;
    padding: 32px;
    background: var(--card);
    border: 1px solid var(--secondary-line);
    border-radius: var(--radius);
    box-shadow: none;
}

h1 {
    margin: 0 0 16px;
    color: var(--ink);
    font-size: 30px;
    font-weight: 650;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

p {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
}

p:last-child { margin-bottom: 0; }

.card a {
    color: var(--ink);
    text-underline-offset: 3px;
}

form:not(.logout-form) {
    display: grid;
    gap: 6px;
}

label {
    margin-top: 10px;
    color: var(--nav);
    font-size: 14px;
    font-weight: 500;
}

.optional {
    color: var(--faint);
    font-weight: 400;
}

input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--secondary-line);
    border-radius: var(--control-radius);
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.4 var(--font);
}

form:not(.logout-form) button {
    justify-self: stretch;
    margin-top: 16px;
    min-height: 46px;
    padding: 12px 20px;
    border: 0;
    border-radius: var(--control-radius);
    background: var(--cta);
    color: #ffffff;
    font: 600 14px/1 var(--font);
    cursor: pointer;
}

form:not(.logout-form) button:hover {
    background: var(--cta-hover);
}

.notice {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.alert { color: var(--danger); }

dl { margin: 0; }

dt {
    color: var(--faint);
    font-size: 13px;
    font-weight: 500;
}

dd {
    margin: 0 0 14px;
    color: var(--ink);
    font-size: 16px;
}

dd:last-child { margin-bottom: 0; }

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
}

@media (max-width: 720px) {
    .m-bar {
        gap: 14px;
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .site-nav {
        flex-wrap: wrap;
        gap: 12px;
    }

    .stage { padding: 24px 16px 56px; }
}

@media (max-width: 640px) {
    .app-grid { grid-template-columns: 1fr; }
}
