/* Arkana Roadmap stylesheet.
 *
 * The design tokens mirror papermapgenerator/paperminigenerator (css/theme.css
 * in each): dark navy background, dark navy cards, red primary with gradient
 * buttons, Kanit type — so the roadmap reads as the same brand. The layout
 * rules are this app's own; only tokens and component looks are shared.
 *
 * Templates may still carry inline style="" attributes, but only for
 * data-driven values (status chip colors via --chip, matrix dot positions).
 */

@font-face {
    font-family: 'Kanit';
    font-weight: 300;
    font-display: swap;
    src: url('/static/fonts/Kanit-Light.ttf') format('truetype');
}
@font-face {
    font-family: 'Kanit';
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/Kanit-Regular.ttf') format('truetype');
}
@font-face {
    font-family: 'Kanit';
    font-weight: 500;
    font-display: swap;
    src: url('/static/fonts/Kanit-Medium.ttf') format('truetype');
}
@font-face {
    font-family: 'Kanit';
    font-weight: 600;
    font-display: swap;
    src: url('/static/fonts/Kanit-SemiBold.ttf') format('truetype');
}

:root {
    /* Shared Arkana palette (theme.css names in comments) */
    --bg: #01041D;             /* --main-background */
    --card: #0E1129;           /* --secondary-darker */
    --card-deep: #0C0E22;      /* --secondary-darkest */
    --border: #1A1D33;         /* --secondary-dark */
    --fg: #CCCDD2;             /* --secondary-lighter */
    --muted: #676877;          /* --secondary-light */
    --accent: #DF5959;         /* --primary-light: link/hover red that reads on dark */
    --accent-strong: #DF2D2D;  /* --primary */
    --accent-soft: #DF8686;    /* --primary-lighter */

    --button-primary1: #9E0B0F;
    --button-primary2: #E61720;
    --button-hover1: #CE1016;
    --button-hover2: #E61729;
    --button-clicked1: #59090C;
    --button-clicked2: #9E0B0F;
    --button-border: #E61720;
    --button-clicked-border: #9E0B0F;

    --input-bg: rgba(255, 255, 255, 0.07);
    --input-border: rgba(255, 255, 255, 0.2);
    --hover-bg: rgba(255, 255, 255, 0.05);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
    margin: 0;
    font-family: 'Kanit', system-ui, sans-serif;
    font-weight: 300;
    background: var(--bg);
    color: var(--fg);
}
h1, h2, h3, h4 { font-weight: 500; }
a { color: var(--accent); }
a:hover { color: var(--accent-soft); }
code {
    font-family: ui-monospace, monospace;
    font-size: 0.9em;
    background: var(--input-bg);
    border-radius: 4px;
    padding: 0.05em 0.35em;
}
pre {
    background: var(--card-deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    overflow-x: auto;
}
pre code { background: none; padding: 0; }
blockquote {
    margin: 0.75rem 0;
    padding-left: 0.9rem;
    border-left: 3px solid var(--border);
    color: var(--muted);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
summary { cursor: pointer; }

/* ---- Site chrome ---- */
header.site {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
header.site .brand {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--accent-strong);
    text-decoration: none;
}
header.site nav a { color: var(--fg); text-decoration: none; margin-right: 1rem; }
header.site nav a:hover { color: var(--accent); }
header.site .auth { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
header.site .nav-search input {
    font-size: 0.85rem; padding: 0.3rem 0.6rem; width: 11rem;
}
header.site .auth .tier {
    background: var(--input-bg); border: 1px solid var(--border);
    border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 0.8rem; color: var(--muted);
}
main { max-width: 60rem; margin: 0 auto; padding: 1.5rem; }
main.wide { max-width: none; }

/* ---- Buttons ---- */
.btn, header.site .auth button {
    background-image: linear-gradient(var(--button-primary1), var(--button-primary2));
    border: 1px solid var(--button-border);
    color: #fff; border-radius: 6px;
    padding: 0.4rem 0.9rem; font: inherit; font-weight: 500; font-size: 0.9rem;
    cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover, header.site .auth button:hover {
    background-image: linear-gradient(var(--button-hover1), var(--button-hover2));
    color: #fff;
}
.btn:active, header.site .auth button:active {
    background-image: linear-gradient(var(--button-clicked1), var(--button-clicked2));
    border-color: var(--button-clicked-border);
}
.link-btn {
    background: none; border: none; color: var(--accent); cursor: pointer;
    font: inherit; padding: 0; text-decoration: underline;
}
.link-btn:hover { color: var(--accent-soft); }
.link-btn:disabled { color: var(--muted); text-decoration: none; cursor: default; }

/* ---- Forms ---- */
input[type="text"], input[type="search"], input[type="number"], textarea, select {
    font: inherit; font-weight: 400; padding: 0.5rem;
    border: 1px solid var(--input-border); border-radius: 6px;
    background: var(--input-bg); color: var(--fg);
}
::placeholder { color: var(--muted); opacity: 1; }
option { background: var(--card); color: var(--fg); }
input[type="number"] { width: 5.5rem; }
input[type="color"] {
    width: 2.4rem; height: 2.2rem; padding: 2px;
    border: 1px solid var(--input-border); border-radius: 6px;
    background: var(--input-bg); cursor: pointer;
}
.file-input { font-size: 0.85rem; color: var(--muted); }
.file-input::file-selector-button {
    font: inherit; color: var(--fg);
    background: var(--input-bg); border: 1px solid var(--input-border);
    border-radius: 6px; padding: 0.3rem 0.7rem; margin-right: 0.6rem; cursor: pointer;
}
.file-input::file-selector-button:hover { background: var(--input-border); }
.inline-form { display: inline-flex; gap: 0.5rem; align-items: center; }
.hidden { display: none !important; }
/* Admin merge control on the post card: a collapsed "Merge…" that opens
   into an inline target form next to it (app.js data-toggle). */
.merge-form input { padding: 0.25rem 0.4rem; font-size: 0.85rem; width: 14rem; }
.merge-form { position: relative; }
.merge-form .suggest { position: absolute; top: 100%; left: 0; z-index: 20; min-width: 20rem; max-width: 90vw; }

/* ---- Search suggestions ----
   One fragment, two flavors: a floating dropdown under the merge form's
   target input (.suggest) and a static block under the new-post title
   (.suggest-static). Both clear by swapping in an empty body. */
.suggest-list { list-style: none; padding: 0.25rem; margin: 0; }
.suggest-heading { font-size: 0.8rem; padding: 0.3rem 0.6rem 0.1rem; }
.suggest-item {
    display: block; width: 100%; text-align: left;
    font: inherit; font-size: 0.85rem; font-weight: 300; color: var(--fg);
    background: none; border: none; border-radius: 6px;
    padding: 0.35rem 0.6rem; cursor: pointer; text-decoration: none;
}
.suggest-item:hover { background: var(--hover-bg); color: var(--fg); }
.suggest-item .suggest-title { display: block; }
.suggest-item .small { display: block; }
.merge-form .suggest .suggest-list {
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45); margin-top: 0.3rem;
}
.suggest-static .suggest-list {
    background: var(--card-deep); border: 1px solid var(--border); border-radius: 8px;
    margin-bottom: 0.75rem;
}
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.75rem; margin: 0.75rem 0; }
.perm-grid label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }

/* ---- Notices ---- */
.notice-error {
    background: rgba(133, 0, 0, 0.25); border: 1px solid #850000; color: var(--accent-soft);
    border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1rem;
}
.notice-ok {
    background: rgba(34, 197, 94, 0.08); border: 1px solid #14532d; color: #4ade80;
    border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1rem;
}
.notice-ok code, .notice-error code { word-break: break-all; }
.hidden-badge {
    background: rgba(251, 191, 36, 0.12); color: #fbbf24; border-radius: 999px;
    padding: 0 0.5rem; font-size: 0.75rem; margin-left: 0.5rem;
}
.team-badge {
    background: rgba(223, 45, 45, 0.15); color: var(--accent); border-radius: 999px;
    padding: 0 0.5rem; font-size: 0.75rem; font-weight: 500;
}

/* ---- Cards ---- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* ---- Boards + posts ---- */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.board-card { display: block; text-decoration: none; color: inherit; }
.board-card:hover { border-color: var(--accent); color: inherit; }
.board-card h2 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.sort-tabs { display: flex; gap: 0.25rem; margin-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.sort-tabs a {
    padding: 0.35rem 0.9rem; color: var(--muted); text-decoration: none;
    font-size: 0.9rem; font-weight: 500;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.sort-tabs a:hover { color: var(--fg); }
.sort-tabs a.active { color: var(--fg); border-bottom-color: var(--accent-strong); }
.post-list, .comment-list { list-style: none; padding: 0; margin: 0; }
.post-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; padding: 0.75rem 1rem; flex-wrap: wrap; }
.post-title { color: inherit; text-decoration: none; font-weight: 400; flex: 1; min-width: 12rem; }
.post-title:hover { color: var(--accent); }
.post-heading { margin: 0.5rem 0; }
.status-chip {
    display: inline-block; font-size: 0.75rem; font-weight: 500; color: #fff;
    background: var(--chip, var(--muted)); border-radius: 999px; padding: 0.1rem 0.6rem;
    white-space: nowrap;
}
.status-select {
    font: inherit; font-size: 0.8rem; font-weight: 500;
    border: 1px solid var(--input-border); border-radius: 999px;
    padding: 0.1rem 0.5rem; background: var(--input-bg); color: var(--fg); cursor: pointer;
}
.status-select:disabled { opacity: 0.5; cursor: wait; }
.status-history { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0.75rem 0; font-size: 0.85rem; }
.status-step { white-space: nowrap; }
.changelog-month { margin: 1.5rem 0 0.75rem; }
.exp-chip {
    display: inline-block; font-size: 0.75rem; font-weight: 500; color: var(--fg);
    border: 1px dashed var(--muted); border-radius: 999px; padding: 0.1rem 0.6rem;
    white-space: nowrap;
}
.tag-chip { /* outlined in the tag's color, so it never reads as a status */
    display: inline-block; font-size: 0.75rem; font-weight: 500;
    color: var(--chip, var(--muted)); border: 1px solid var(--chip, var(--muted));
    border-radius: 999px; padding: 0.1rem 0.6rem; white-space: nowrap;
}
.changelog-layout { display: flex; gap: 2rem; align-items: flex-start; }
.changelog-content { flex: 1; min-width: 0; }
.changelog-content > h1:first-child { margin-top: 0; }
.tag-nav a { display: flex; align-items: center; gap: 0.5rem; }
.tag-logo { width: 1.1rem; height: 1.1rem; object-fit: contain; }
.tag-dot {
    width: 0.65rem; height: 0.65rem; border-radius: 50%;
    background: var(--chip, var(--muted)); flex: none;
}
.comment { margin-bottom: 0.75rem; }
.comment-hidden { opacity: 0.55; border-style: dashed; }
.comment-pinned { border-color: var(--accent-strong); }
.pin-label {
    color: var(--accent); font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.35rem;
}
.comment-meta { font-size: 0.85rem; margin-bottom: 0.35rem; }
.comment-body p:first-child, .post-body p:first-child { margin-top: 0; }
.comment-body p:last-child, .post-body p:last-child { margin-bottom: 0; }
.post-body img, .comment-body img { max-width: 100%; }

/* ---- Votes ---- */
.vote-chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    font: inherit; font-size: 0.85rem; font-weight: 500;
    border: 1px solid var(--input-border); border-radius: 6px; background: var(--input-bg);
    color: var(--fg); padding: 0.25rem 0.6rem; cursor: pointer; white-space: nowrap;
}
.vote-chip:hover:not(.static) { border-color: var(--accent); color: var(--accent); }
.vote-chip.voted {
    background: linear-gradient(var(--button-primary1), var(--button-primary2));
    border-color: var(--button-border); color: #fff;
}
.vote-chip.voted:hover:not(.static) { color: #fff; border-color: var(--button-border); }
.vote-chip.static { cursor: default; color: var(--muted); }
.vote-chip:disabled { opacity: 0.5; cursor: wait; }

/* ---- Gated features: unlock tooltip with magic text ----
   Ported from papermap/papermini (css/magictext.css + the tippy "patreon"
   theme): hovering a gated control shows a dark tooltip where "Arkana Tools"
   shimmers in the red gradient with popping stars (star positions are
   randomized in app.js). Pure CSS + 'self' JS, so the CSP stays intact. */
.gate { position: relative; display: inline-block; }
.gate-mark { border-bottom: 1px dashed var(--muted); cursor: help; }
.gate-tip {
    position: absolute; bottom: 100%; left: -0.6rem; z-index: 30;
    width: max-content; max-width: min(18rem, 85vw);
    background: #34364A; /* --secondary, the tools' tooltip background */
    color: var(--fg); border-radius: 6px;
    padding: 0.45rem 0.8rem; font-size: 0.85rem; font-weight: 400;
    opacity: 0; pointer-events: none;
    transform: scale(0.85); transform-origin: bottom left;
    transition: transform 150ms ease, opacity 150ms ease;
}
.gate-tip::after { /* arrow, bridges the hover area to the trigger */
    content: ""; position: absolute; top: 100%; left: 1.1rem;
    border: 6px solid transparent; border-top-color: #34364A;
}
.gate:hover .gate-tip, .gate:focus-within .gate-tip {
    opacity: 1; transform: scale(1); pointer-events: auto;
}
.gate-tip a { color: inherit; }

@keyframes background-pan {
    from { background-position: 0% center; }
    to { background-position: -200% center; }
}
@keyframes star-scale {
    from, to { transform: scale(0); }
    50% { transform: scale(1); }
}
@keyframes star-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(180deg); }
}
.magic { display: inline-block; position: relative; }
.magic-star {
    --size: clamp(16px, 1.2vw, 24px);
    animation: star-scale 700ms ease forwards;
    display: block; position: absolute;
    height: var(--size); width: var(--size);
    left: var(--star-left, 20%); top: var(--star-top, -30%);
    pointer-events: none;
}
.magic-star > svg { animation: star-rotate 1000ms linear infinite; display: block; opacity: 0.7; }
.magic-star > svg > path { fill: #DF2D2D; }
.magic-text {
    animation: background-pan 3s linear infinite;
    background: linear-gradient(to right, #DF2D2D, #DF5959, #DF8686, #DF2D2D);
    background-size: 200%;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    white-space: nowrap;
}
.magic-text a { text-decoration: none; }

/* ---- Attachments ---- */
.attachments { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; align-items: flex-start; }
.attachments img {
    display: block; max-height: 12rem; max-width: 100%;
    border: 1px solid var(--border); border-radius: 6px;
}
.attachments video { max-width: 100%; max-height: 18rem; border-radius: 6px; background: #000; }
.attachment-file {
    display: inline-block; padding: 0.35rem 0.7rem; font-size: 0.85rem;
    border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg);
    color: var(--fg); text-decoration: none;
}
.attachment-file:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Kanban ---- */
/* Columns wrap instead of scrolling sideways: full row on wide
   screens, stacked single column on phones. */
.kanban { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.kanban-col { flex: 1 1 15rem; min-width: 0; }
.kanban-col > header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.kanban-list { list-style: none; padding: 0; margin: 0; min-height: 3rem; }
.kanban-card { padding: 0.6rem 0.8rem; margin-bottom: 0.5rem; }
.kanban-list.sortable .kanban-card { cursor: grab; }
.kanban-card .post-title { display: block; font-size: 0.9rem; }
.kanban-meta { font-size: 0.78rem; }
/* Card footer: meta on the left, the post's tool tag bottom-right. */
.kanban-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-top: 0.25rem; }
.tag-chip-sm { font-size: 0.68rem; padding: 0 0.45rem; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
.sortable-ghost { opacity: 0.4; }

/* ---- Effort/impact matrix ---- */
.matrix-wrap { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0.5rem; }
.matrix-toolbar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
/* The viewport clips a pannable/zoomable 1000×1000px "world" holding
   the 0-100 effort/impact space. */
.matrix-viewport {
    position: relative; overflow: hidden;
    height: calc(100vh - 17rem); min-height: 22rem;
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    touch-action: none; /* wheel/pinch/drag handled in JS */
    cursor: grab;
}
.matrix-world {
    position: absolute; left: 0; top: 0; width: 1000px; height: 1000px;
    transform-origin: 0 0;
    background: var(--card);
    background-image: linear-gradient(var(--border) 1px, transparent 1px),
                      linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 100px 100px;
    border: 1px solid var(--border);
}
.matrix-dot {
    position: absolute;
    /* transform-origin 0 0 is load-bearing: with it, scale-then-
       translate keeps the circle's center pinned on the data point
       while --dot-scale (1/zoom) holds the chip at constant screen
       size. The default (center) origin makes dots drift on zoom. */
    transform-origin: 0 0;
    transform: scale(var(--dot-scale, 1)) translate(-0.8rem, -50%);
    display: inline-flex; align-items: center; gap: 0.3rem; max-width: 12rem;
    cursor: grab;
}
.matrix-dot.unplaced { opacity: 0.45; }
.matrix-dot .dot {
    width: 1.6rem; height: 1.6rem; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.7rem; font-weight: 600;
    background: var(--chip, var(--muted)); border: 1px solid rgba(255, 255, 255, 0.2);
}
.matrix-label {
    font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: inherit; text-decoration: none;
}
a.matrix-label:hover { color: var(--accent); text-decoration: underline; }
.axis-y { writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; font-size: 0.85rem; }
.axis-x { text-align: center; font-size: 0.85rem; }

/* ---- Admin ---- */
/* Admin pages run full-width regardless of main's 60rem cap, so the sidebar
   sits in the exact same spot on every admin page. */
main:has(> .admin-layout) { max-width: none; }
.admin-layout { display: flex; gap: 2rem; align-items: flex-start; }
.admin-content { flex: 1; min-width: 0; }
.admin-content > h1:first-child { margin-top: 0; }
.admin-nav, .tag-nav {
    flex: 0 0 10.5rem;
    display: flex; flex-direction: column; gap: 0.15rem;
    position: sticky; top: 1rem;
}
.admin-nav a, .tag-nav a {
    color: var(--muted); text-decoration: none;
    padding: 0.4rem 0.75rem; font-weight: 400;
    border-left: 2px solid transparent; border-radius: 0 6px 6px 0;
}
.admin-nav a:hover, .tag-nav a:hover { color: var(--fg); background: var(--hover-bg); }
.admin-nav a.active, .tag-nav a.active { color: var(--fg); background: var(--card); border-left-color: var(--accent-strong); }
@media (max-width: 45rem) {
    .admin-layout, .changelog-layout { display: block; }
    .admin-nav, .tag-nav {
        position: static; flex-direction: row; flex-wrap: wrap;
        margin-bottom: 1rem;
    }
    .admin-nav a, .tag-nav a { border-left: none; border-radius: 6px; }
}
.admin-table { border-collapse: collapse; width: 100%; }
.admin-table th, .admin-table td { text-align: left; padding: 0.4rem 0.75rem 0.4rem 0; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.danger-zone { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.danger-zone > :first-child { margin-top: 0; }

/* ---- Utilities ---- */
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hint { font-size: 0.8rem; }
.nowrap { white-space: nowrap; }
.w-full { width: 100%; }
.w-md { width: 14rem; max-width: 100%; }
.w-lg { width: 24rem; max-width: 100%; }
.mt { margin-top: 1rem; }
.ml { margin-left: 0.5rem; }
.mb { margin-bottom: 1.5rem; }
.mb-sm { margin-bottom: 0.75rem; }
