/* ============================================================
   TAVERN THEME — loaded after styles.css, overrides the look
   Dark oak taproom at candlelight. Brass fittings, wax seals,
   and one parchment scroll: the quest log.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@600;800&family=IM+Fell+English&family=Comic+Neue:wght@400;700&display=swap");

html[data-theme="tavern"] {
    --bg: #17100a;
    --panel: rgba(38, 24, 13, 0.94);
    --panel2: rgba(48, 31, 17, 0.96);
    --border: rgba(201, 151, 63, 0.45);
    --gold: #e8b354;
    --ember: #e0862c;
    --blue: #e8b354;          /* old blue accents become brass */
    --green: #9fbf7a;         /* mossy green for success */
    --rose: #d98e5f;          /* warm copper replaces pink */
    --text: #f0e2c4;
    --muted: #c9b491;
    --danger: #b23a2f;        /* wax-seal red */
    --ink: #2f2113;
    --parchment: #e6d5ae;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    --display-font: "Cinzel", Georgia, "Times New Roman", serif;
    --body-font: "IM Fell English", Georgia, "Palatino Linotype", serif;
}

html[data-theme="tavern"] body {
    font-family: var(--body-font);
    background:
        radial-gradient(ellipse at 22% -8%, rgba(224, 134, 44, 0.20), transparent 42%),
        radial-gradient(ellipse at 82% 0%, rgba(224, 134, 44, 0.13), transparent 38%),
        radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, 0.6), transparent 60%),
        url("theme/wood.svg");
    background-color: #17100a;
    background-size: auto, auto, auto, 480px 480px;
}

/* soft candle flicker across the whole room */
html[data-theme="tavern"] body::before {
    background:
        radial-gradient(circle at 15% 6%, rgba(232, 179, 84, 0.10), transparent 26%),
        radial-gradient(circle at 88% 4%, rgba(232, 179, 84, 0.08), transparent 24%);
    background-size: auto;
    /* candle-breathe animation removed: it animated opacity on a full-viewport
       ::before gradient every frame, forcing a whole-screen repaint that lagged
       low-power clients. The warm glow still shows, just without the pulse. */
    opacity: 0.9;
}

@keyframes candle-breathe {
    from { opacity: 0.75; }
    to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    html[data-theme="tavern"] body::before { animation: none; }
}

/* ---------- top bar: the tavern lintel ---------- */

html[data-theme="tavern"] .topbar {
    background: linear-gradient(180deg, rgba(24, 14, 7, 0.97), rgba(33, 20, 10, 0.94));
    border-bottom: 2px solid #0c0703;
    box-shadow: 0 1px 0 rgba(201, 151, 63, 0.35), 0 10px 30px rgba(0, 0, 0, 0.5);
}

html[data-theme="tavern"] .brand {
    font-family: var(--display-font);
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--gold);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

html[data-theme="tavern"] .brand::before {
    content: "🍺 ";
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.7));
}

html[data-theme="tavern"] .account-pill {
    border-color: rgba(201, 151, 63, 0.4);
    color: var(--gold);
    background: rgba(0, 0, 0, 0.3);
    font-style: italic;
}

/* ---------- buttons: brass-bound leather ---------- */

html[data-theme="tavern"] .topbar a,
html[data-theme="tavern"] .button,
html[data-theme="tavern"] button {
    font-family: var(--display-font);
    font-weight: 600;
    font-size: 0.86rem;
    letter-spacing: 0.03em;
    color: var(--text);
    background: linear-gradient(180deg, #4a2f16, #33200e);
    border: 1px solid rgba(201, 151, 63, 0.55);
    border-radius: 8px;
    box-shadow:
        inset 0 1px 0 rgba(232, 179, 84, 0.25),
        0 4px 12px rgba(0, 0, 0, 0.45);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

html[data-theme="tavern"] button:hover,
html[data-theme="tavern"] .button:hover,
html[data-theme="tavern"] .topbar a:hover {
    filter: none;
    transform: translateY(-1px);
    background: linear-gradient(180deg, #5d3c1c, #402812);
    border-color: var(--gold);
    box-shadow:
        inset 0 1px 0 rgba(232, 179, 84, 0.35),
        0 0 14px rgba(224, 134, 44, 0.35),
        0 6px 14px rgba(0, 0, 0, 0.5);
}

html[data-theme="tavern"] button.danger,
html[data-theme="tavern"] .danger {
    color: #ffe9d6;
    background: linear-gradient(180deg, #8f3126, #63201a);
    border-color: rgba(217, 122, 95, 0.55);
}

html[data-theme="tavern"] button.danger:hover,
html[data-theme="tavern"] .danger:hover {
    background: linear-gradient(180deg, #a63b2e, #732620);
}

html[data-theme="tavern"] .tool.active {
    background: linear-gradient(180deg, #7a5220, #5b3a13);
    border-color: var(--gold);
    color: #ffe9bd;
    box-shadow: inset 0 1px 0 rgba(255, 226, 150, 0.4), 0 0 12px rgba(224, 134, 44, 0.45);
}

/* ---------- panels: dark oak boards ---------- */

html[data-theme="tavern"] .sheet-card,
html[data-theme="tavern"] .side-panel,
html[data-theme="tavern"] .right-panel,
html[data-theme="tavern"] .board-shell,
html[data-theme="tavern"] .map-selector-modal,
html[data-theme="tavern"] .home-tile,
html[data-theme="tavern"] .hero,
html[data-theme="tavern"] details {
    background: var(--panel);
    border-color: var(--border);
}

html[data-theme="tavern"] .side-panel details,
html[data-theme="tavern"] .right-panel details {
    background: linear-gradient(180deg, rgba(46, 29, 15, 0.9), rgba(36, 22, 11, 0.92));
    border: 1px solid rgba(201, 151, 63, 0.3);
    border-radius: 10px;
}

html[data-theme="tavern"] details > summary {
    font-family: var(--display-font);
    letter-spacing: 0.05em;
    color: var(--gold);
}

html[data-theme="tavern"] h1,
html[data-theme="tavern"] h2,
html[data-theme="tavern"] h3,
html[data-theme="tavern"] h4 {
    font-family: var(--display-font);
    letter-spacing: 0.04em;
    color: var(--gold);
}

html[data-theme="tavern"] label {
    color: var(--muted);
    font-style: italic;
}

html[data-theme="tavern"] input,
html[data-theme="tavern"] select,
html[data-theme="tavern"] textarea {
    background: rgba(15, 9, 4, 0.75);
    border: 1px solid rgba(201, 151, 63, 0.35);
    color: var(--text);
    border-radius: 6px;
    font-family: var(--body-font);
}

html[data-theme="tavern"] input:focus,
html[data-theme="tavern"] select:focus,
html[data-theme="tavern"] textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(224, 134, 44, 0.3);
}

html[data-theme="tavern"] .flash {
    background: linear-gradient(180deg, #4a2f16, #33200e);
    border: 1px solid var(--gold);
    color: var(--text);
    font-style: italic;
}

/* ---------- home page ---------- */

html[data-theme="tavern"] .hero {
    border: 1px solid var(--border);
    background:
        radial-gradient(ellipse at 50% -30%, rgba(224, 134, 44, 0.22), transparent 60%),
        var(--panel);
}

html[data-theme="tavern"] .hero h1 { font-size: 2.2rem; }

html[data-theme="tavern"] .home-tile:hover {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(224, 134, 44, 0.3), var(--shadow);
}

/* ---------- map table: the board sits on the tavern table ---------- */

html[data-theme="tavern"] .map-viewport {
    border: 10px solid transparent;
    border-image: linear-gradient(140deg, #5a3a19, #2c1a0b 40%, #4a2f14 70%, #241407) 1;
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.7),
        0 12px 40px rgba(0, 0, 0, 0.6);
    background: #0d0803;
}

/* ---------- THE SIGNATURE: parchment quest scroll ---------- */

html[data-theme="tavern"] .quest-box .quest-card,
html[data-theme="tavern"] .quest-card {
    position: relative;
    background: url("theme/parchment.svg");
    background-size: 420px 420px;
    background-color: var(--parchment);
    color: var(--ink);
    border: none;
    border-radius: 4px;
    padding: 16px 16px 18px;
    box-shadow:
        inset 0 0 30px rgba(94, 66, 24, 0.35),
        0 6px 18px rgba(0, 0, 0, 0.55);
    /* torn / burned edge */
    clip-path: polygon(
        0% 2%, 3% 0%, 12% 1.5%, 25% 0.3%, 40% 1.8%, 55% 0.2%, 70% 1.5%,
        84% 0.4%, 96% 1.8%, 100% 3%, 99.3% 15%, 100% 30%, 98.8% 48%,
        100% 66%, 99% 82%, 100% 96%, 97% 100%, 84% 98.6%, 68% 100%,
        52% 98.4%, 36% 100%, 20% 98.7%, 7% 100%, 0% 97%, 1.2% 80%,
        0% 62%, 1% 45%, 0% 26%, 1.4% 12%
    );
}

html[data-theme="tavern"] .quest-card h3 {
    font-family: var(--display-font);
    color: #4a2c0e;
    margin-top: 2px;
    border-bottom: 2px solid rgba(74, 44, 14, 0.35);
    padding-bottom: 6px;
    text-shadow: none;
}

html[data-theme="tavern"] .quest-card p {
    color: var(--ink);
    font-style: italic;
    line-height: 1.45;
}

html[data-theme="tavern"] .quest-objective {
    color: var(--ink);
    padding: 3px 0;
    font-size: 1rem;
}

html[data-theme="tavern"] .quest-objective span:first-child {
    color: #8a1f1a; /* wax-seal red bullet */
    font-weight: 700;
}

html[data-theme="tavern"] .quest-objective.done {
    opacity: 0.45;
    text-decoration: line-through;
    text-decoration-thickness: 2px;
    text-decoration-color: #6b4a20; /* faded ink strike */
}

html[data-theme="tavern"] .quest-objective.done span:first-child {
    color: #6b4a20;
}

/* ---------- chat: the table talk ---------- */

html[data-theme="tavern"] .chat-log { background: rgba(12, 7, 3, 0.6); border-radius: 8px; }

html[data-theme="tavern"] .chat-message strong { color: var(--gold); font-family: var(--display-font); font-size: 0.82rem; }

html[data-theme="tavern"] .roll-result {
    background: rgba(224, 134, 44, 0.12);
    border: 1px solid rgba(224, 134, 44, 0.35);
    border-radius: 6px;
    color: #ffd98f;
    padding: 3px 8px;
}

/* ---------- shops modal: entering the town ---------- */

html[data-theme="tavern"] .v099-shop-card,
html[data-theme="tavern"] .town-store-card,
html[data-theme="tavern"] .quest-list-card {
    background: linear-gradient(180deg, rgba(52, 33, 17, 0.95), rgba(38, 23, 11, 0.95));
    border: 1px solid rgba(201, 151, 63, 0.35);
    color: var(--text);
}

html[data-theme="tavern"] .v099-shop-card strong,
html[data-theme="tavern"] .town-store-card strong,
html[data-theme="tavern"] .quest-list-card strong {
    color: var(--gold);
}

html[data-theme="tavern"] .v099-shop-card:hover,
html[data-theme="tavern"] .town-store-card:hover,
html[data-theme="tavern"] .quest-list-card:hover {
    border-color: var(--gold);
    box-shadow: 0 0 16px rgba(224, 134, 44, 0.3);
    transform: translateY(-2px);
}

html[data-theme="tavern"] .v099-shop-type {
    color: var(--ember);
    font-family: var(--display-font);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.72rem;
}

html[data-theme="tavern"] .v099-stock-card {
    background: rgba(20, 12, 6, 0.75);
    border: 1px solid rgba(201, 151, 63, 0.28);
}

html[data-theme="tavern"] .badge {
    background: rgba(224, 134, 44, 0.15);
    border: 1px solid rgba(224, 134, 44, 0.45);
    color: #ffd98f;
    border-radius: 999px;
    font-family: var(--display-font);
    font-size: 0.72rem;
}

html[data-theme="tavern"] .badge.player-sold {
    background: rgba(178, 58, 47, 0.2);
    border-color: rgba(178, 58, 47, 0.6);
    color: #ffb3a6;
}

html[data-theme="tavern"] .badge.buyback-grace {
    background: rgba(159, 191, 122, 0.2);
    border-color: rgba(159, 191, 122, 0.6);
    color: #c8e6a9;
}

html[data-theme="tavern"] .town-enter-button {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    background: linear-gradient(180deg, #6b451c, #4a2d10);
    border: 1px solid var(--gold);
    box-shadow: inset 0 1px 0 rgba(255, 220, 150, 0.3), 0 0 16px rgba(224, 134, 44, 0.25);
}

html[data-theme="tavern"] .town-enter-button::before { content: "🏘 "; }

html[data-theme="tavern"] .shops-town-summary strong { font-family: var(--display-font); color: var(--gold); }

/* ---------- quest board: corkboard with pinned notes ---------- */

html[data-theme="tavern"] .quest-corkboard {
    column-width: 230px;
    column-gap: 22px;
    padding: 28px 20px 4px;
    background:
        repeating-linear-gradient(0deg, rgba(0,0,0,0.08) 0 2px, transparent 2px 4px),
        repeating-linear-gradient(90deg, rgba(0,0,0,0.06) 0 2px, transparent 2px 4px),
        radial-gradient(circle at 20% 15%, rgba(0,0,0,0.15), transparent 45%),
        radial-gradient(circle at 80% 85%, rgba(0,0,0,0.15), transparent 45%),
        #a9784f;
    border: 10px solid #5a3a1e;
    border-radius: 6px;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.55), 0 10px 30px rgba(0,0,0,0.5);
}

html[data-theme="tavern"] .quest-board-note {
    position: relative;
    display: inline-block;
    width: 100%;
    break-inside: avoid;
    background: url("theme/parchment.svg");
    background-size: 420px 420px;
    background-color: var(--parchment);
    color: var(--ink);
    padding: 18px 14px 14px;
    border-radius: 2px;
    /* --tilt and --stagger are set per-note inline, from a hash of the
       quest id, so the scatter is stable across re-renders instead of
       reshuffling every time the board redraws. */
    margin: 0 0 calc(24px + var(--stagger, 0px));
    transform: rotate(var(--tilt, -2deg)) translateX(var(--drift, 0px));
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    transition: transform 150ms ease;
}

html[data-theme="tavern"] .quest-board-note:hover {
    transform: rotate(var(--tilt, -2deg)) translateX(var(--drift, 0px)) translateY(-3px) scale(1.02);
    z-index: 2;
}

html[data-theme="tavern"] .quest-board-pin {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    filter: drop-shadow(0 3px 3px rgba(0,0,0,0.6));
    line-height: 1;
}

html[data-theme="tavern"] .quest-board-pin-dagger {
    transform: translateX(-50%) rotate(-38deg);
    top: -12px;
}

html[data-theme="tavern"] .quest-board-pin-nail {
    display: inline-flex;
}

html[data-theme="tavern"] .quest-board-note h4 {
    font-family: var(--display-font);
    color: #4a2c0e;
    margin: 4px 0 6px;
    border-bottom: 1px solid rgba(74, 44, 14, 0.3);
    padding-bottom: 4px;
}

html[data-theme="tavern"] .quest-board-note p {
    font-style: italic;
    font-size: 0.88rem;
    margin: 0 0 8px;
}

html[data-theme="tavern"] .quest-board-objectives {
    margin: 0 0 10px;
    padding-left: 18px;
    font-size: 0.84rem;
}

html[data-theme="tavern"] .quest-board-note button {
    width: 100%;
}

html[data-theme="tavern"] .quest-board-accepted-badge {
    display: block;
    text-align: center;
    padding: 8px;
}

html[data-theme="tavern"] .quest-board-picker {
    display: grid;
    gap: 6px;
    margin: 10px 0 16px;
}

html[data-theme="tavern"] .quest-board-picker-row {
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(0,0,0,0.2);
}

html[data-theme="tavern"] .quest-acceptances-box {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px dashed rgba(201, 151, 63, 0.4);
}

html[data-theme="tavern"] .quest-acceptance-list {
    display: grid;
    gap: 8px;
}

html[data-theme="tavern"] .quest-acceptance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(224, 134, 44, 0.1);
    border: 1px solid rgba(224, 134, 44, 0.3);
}

html[data-theme="tavern"] .quest-acceptance-actions {
    display: flex;
    gap: 8px;
}

html[data-theme="tavern"] .trade-offer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(159, 191, 122, 0.08);
    border: 1px solid rgba(159, 191, 122, 0.3);
    margin-bottom: 6px;
}

html[data-theme="tavern"] .trade-offer-actions {
    display: flex;
    gap: 8px;
}

html[data-theme="tavern"] .town-map-bind-list {
    display: grid;
    gap: 6px;
    margin: 10px 0 12px;
}

html[data-theme="tavern"] .town-map-bind-row {
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(0,0,0,0.2);
}

html[data-theme="tavern"] .trap-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 0.95rem;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.7));
    z-index: 3;
}

html[data-theme="tavern"] .torch-burning {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: 10px;
    background: rgba(224, 134, 44, 0.15);
    border: 1px solid rgba(224, 134, 44, 0.4);
    font-family: var(--display-font);
    color: #ffd98f;
}

html[data-theme="tavern"] .direct-sell-panel {
    border-top: 1px dashed rgba(201, 151, 63, 0.4);
    margin-top: 14px;
    padding-top: 10px;
}

/* ---------- dice popover ---------- */

html[data-theme="tavern"] #dice-toggle::before { content: "🎲 "; }

html[data-theme="tavern"] .dice-popover {
    position: fixed;
    top: 64px;
    right: 16px;
    z-index: 80;
    display: none;
    width: 262px;
    padding: 14px;
    background:
        radial-gradient(ellipse at 50% -20%, rgba(224, 134, 44, 0.18), transparent 60%),
        var(--panel2);
    border: 1px solid var(--gold);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

html[data-theme="tavern"] .dice-popover.open { display: block; }

html[data-theme="tavern"] .dice-popover h3 {
    margin: 0 0 10px;
    font-size: 1rem;
    text-align: center;
}

html[data-theme="tavern"] .dice-popover-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

html[data-theme="tavern"] .dice-popover-grid button {
    padding: 10px 4px;
    font-size: 0.9rem;
}

html[data-theme="tavern"] .dice-popover-grid button[data-die="20"] {
    grid-column: span 2;
    background: linear-gradient(180deg, #7a5220, #5b3a13);
    border-color: var(--gold);
}

html[data-theme="tavern"] .dice-popover-result {
    margin-top: 10px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(12, 7, 3, 0.7);
    border: 1px dashed rgba(201, 151, 63, 0.4);
    border-radius: 8px;
    font-family: var(--display-font);
    color: #ffd98f;
    font-size: 1.05rem;
    padding: 6px;
    text-align: center;
}

html[data-theme="tavern"] .dice-popover-result .die-total {
    font-size: 1.5rem;
    color: var(--gold);
}

html[data-theme="tavern"] .dice-popover .hint { text-align: center; }

/* ---------- login: table code field ---------- */

html[data-theme="tavern"] .code-input {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-family: var(--display-font);
    text-align: center;
}

html[data-theme="tavern"] .login-code-hint {
    line-height: 1.5;
}

/* ---------- admin dashboard & party page ---------- */

/* Structural rules for administration and party account rows now live in
   styles.css so every appearance theme keeps the same layout. Tavern only
   supplies the shared palette and typography. */

html[data-theme="tavern"] .small-button {
    padding: 6px 10px;
    font-size: 0.78rem;
}

html[data-theme="tavern"] .code-pill {
    font-family: var(--display-font);
    letter-spacing: 0.1em;
    font-size: 0.85rem;
}

html[data-theme="tavern"] .big-code {
    font-size: 1.3rem;
    padding: 6px 14px;
    display: inline-block;
}

html[data-theme="tavern"] .table-code-display {
    display: grid;
    gap: 6px;
    margin-bottom: 4px;
}

html[data-theme="tavern"] .account-card {
    max-width: 460px;
}

/* keyboard focus visibility */
html[data-theme="tavern"] a:focus-visible,
html[data-theme="tavern"] button:focus-visible,
html[data-theme="tavern"] input:focus-visible,
html[data-theme="tavern"] select:focus-visible,
html[data-theme="tavern"] textarea:focus-visible,
html[data-theme="tavern"] summary:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* ---------- arrow-key movement: blocked-by-wall feedback ---------- */

@keyframes token-bump {
    0%   { transform: translate(-50%, -50%) translate(0, 0); }
    25%  { transform: translate(-50%, -50%) translate(var(--bump-x, 6px), var(--bump-y, 0)); }
    50%  { transform: translate(-50%, -50%) translate(calc(var(--bump-x, 6px) * -0.6), calc(var(--bump-y, 0) * -0.6)); }
    75%  { transform: translate(-50%, -50%) translate(calc(var(--bump-x, 6px) * 0.3), calc(var(--bump-y, 0) * 0.3)); }
    100% { transform: translate(-50%, -50%) translate(0, 0); }
}

html[data-theme="tavern"] .token.token-bump {
    animation: token-bump 220ms ease;
    border-color: rgba(178, 58, 47, 0.9);
}
