/* Guidance (web/js/guide.js, glossary.js): the phase tracker in the
   header, the "what now" hint over the board, the settings menu, keyword
   underlines with their help, and the auto-continue countdown ring. */

/* --- Phase tracker --- */

.phase-track {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 0;
}

.phase-step {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.4375rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--text-muted);
    transition: background 0.25s, color 0.25s;
}

.phase-step + .phase-step::before {
    content: "";
    width: 0.625rem;
    height: 1px;
    margin-right: 0.25rem;
    background: var(--border-light);
}

.phase-dot {
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 50%;
    border: 1px solid currentColor;
    flex: none;
}

.phase-step--done { color: color-mix(in srgb, var(--accent) 60%, var(--text-muted)); }
.phase-step--done .phase-dot { background: currentColor; }

.phase-step--current {
    background: var(--accent);
    color: var(--bg);
    box-shadow: 0 0 0.75rem color-mix(in srgb, var(--accent) 45%, transparent);
}
.phase-step--current .phase-dot { background: var(--bg); border-color: var(--bg); }

/* Narrow screens: dots for the phases, the name only for the current one. */
@media (max-width: 900px) {
    .phase-step:not(.phase-step--current) .phase-name { display: none; }
    .phase-step:not(.phase-step--current) { padding: 0.125rem 0.1875rem; }
    .phase-step + .phase-step::before { width: 0.3125rem; margin-right: 0.125rem; }
}

@media (max-width: 480px) {
    .game-header .active-player { display: none; } /* the hint and the turn marks say whose turn it is */
    .phase-step { font-size: 0.6rem; padding: 0.125rem 0.3125rem; }
    .phase-step:not(.phase-step--current) { padding: 0.125rem 1px; }
    .phase-step + .phase-step::before { display: none; }
}

/* --- "What now" hint --- */

.guide-hint {
    position: absolute;
    top: 0.625rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 16;
    max-width: min(38.75rem, calc(100% - 2 * 13.75rem));
    width: max-content;
    min-width: 0;
    padding: 0.35rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: var(--glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.35;
    text-align: center;
    box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.3);
}

.guide-hint[hidden] { display: none; }

.guide-hint--you {
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.3), 0 0 0.875rem var(--accent-dim);
}

.guide-hint.is-new { animation: guide-hint-in 0.3s ease; }

@keyframes guide-hint-in {
    from { opacity: 0; transform: translate(-50%, -0.375rem); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* While drawn cards are on show the reveal says why and what follows, and
   its Continue is the next step; the hint would sit under its title. */
body:has(#card-reveal:not([hidden])) #guide-hint { visibility: hidden; }

/* The hint says who we are waiting for. */
#waiting-indicator { display: none !important; }

/* With the tile card up (right), sit between the other players' cards
   (left, 14.25rem) and the card (--tc-room, style.css). */
@media (min-width: 769px) {
    .board-viewport:has(#tile-closeup:not([hidden]):not(.is-suppressed)) .guide-hint {
        left: calc((14.25rem + 100% - var(--tc-room)) / 2);
        max-width: calc(100% - 14.25rem - var(--tc-room) - var(--gutter));
    }
}

@media (max-width: 768px) {
    .guide-hint {
        top: 0.5rem;
        max-width: calc(100% - 2 * 0.5rem);
        font-size: 0.78rem;
        padding: 0.3rem 0.8rem;
    }
}

/* --- Settings menu --- */

.settings-menu {
    position: fixed;
    top: 2.875rem; /* under the header */
    right: var(--gutter);
    z-index: 60;
    width: min(18.75rem, calc(100vw - 2 * var(--gutter)));
    /* Short screens scroll it, so Leave game at its foot stays reachable. */
    max-height: calc(100dvh - 3.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.6rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
    box-shadow: 0 0.75rem 2.25rem rgba(0, 0, 0, 0.45);
}

.settings-menu[hidden] { display: none; }

.settings-row {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.35rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
}

.settings-row:hover { background: var(--bg-panel-hover); }
.settings-row[hidden] { display: none; }
.settings-row input { flex: none; width: 1rem; height: 1rem; padding: 0; margin: 0.15rem 0 0; accent-color: var(--accent); }
.settings-row small { display: block; margin-top: 0.15rem; color: var(--text-muted); font-size: 0.72rem; line-height: 1.35; }

/* UI size: four buttons in a row, the current one lit. */
.settings-uisize {
    margin-top: 0.4rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border);
}

.settings-seg {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
    margin: 0.25rem 0.35rem 0.2rem;
    padding: 2px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg);
}

.settings-seg-btn {
    min-width: 0;
    padding: 0.35rem 0.2rem;
    border: 0;
    border-radius: calc(var(--radius) - 2px);
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.75rem;
    line-height: 1.2;
    cursor: pointer;
}

.settings-seg-btn:hover { color: var(--text); background: var(--bg-panel-hover); }
.settings-seg-btn[aria-checked="true"] { background: var(--accent-dim); color: var(--accent); font-weight: 700; }
.settings-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Sound: a toggle and a volume slider per row. */
.settings-sound {
    margin-top: 0.4rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border);
}

.settings-heading {
    padding: 0 0.35rem 0.2rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
}

.settings-heading small {
    margin-left: 0.4rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-muted);
}

.settings-row--sound { align-items: center; cursor: default; }
.settings-toggle { display: flex; align-items: center; gap: 0.6rem; min-width: 6.2rem; cursor: pointer; }
.settings-toggle input { margin: 0; }
.settings-row--sound input[type="range"] {
    flex: 1;
    width: auto;
    min-width: 0;
    height: 1.5rem; /* a comfortable thumb on phones */
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
.settings-row--sound input[type="range"]:disabled { opacity: 0.4; cursor: default; }

/* --- Keywords --- */

.kw {
    text-decoration: underline dotted;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.125rem;
    text-decoration-color: color-mix(in srgb, currentColor 65%, transparent);
    cursor: help;
    border-radius: 0.125rem;
}

.kw:hover, .kw:focus-visible {
    text-decoration-color: var(--accent);
    background: var(--accent-dim);
    outline: none;
}

.kw-tip {
    position: fixed;
    z-index: 300;
    max-width: 17.5rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--bg-panel);
    color: var(--text);
    font-size: 0.78rem;
    line-height: 1.4;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.45);
    pointer-events: none;
    animation: fade-in 0.12s ease;
}

.kw-tip[hidden] { display: none; }
.kw-tip strong { display: block; color: var(--accent); font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 0.15rem; }

/* --- Auto-continue countdown --- */

.is-auto { position: relative; }

.auto-ring {
    width: 1.125rem;
    height: 1.125rem;
    margin-left: 0.5rem;
    vertical-align: middle;
    flex: none;
    transform: rotate(-90deg);
}

.choice-option.is-auto { display: flex; align-items: center; justify-content: space-between; }

.auto-ring circle { fill: none; stroke-width: 3; }
.auto-ring-track { stroke: color-mix(in srgb, currentColor 25%, transparent); }
.auto-ring-fill {
    stroke: var(--accent);
    stroke-dasharray: 56.55;
    stroke-dashoffset: 56.55;
    stroke-linecap: round;
    animation: auto-ring var(--auto-ms, 1200ms) linear forwards;
}

@keyframes auto-ring { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
    .guide-hint.is-new, .kw-tip { animation: none; }
    .auto-ring-fill { animation-duration: 0s; animation-delay: var(--auto-ms, 1200ms); }
}

/* --- Leaving early (leave.js): a quiet red link-button, then a confirm in place --- */

.settings-leave {
    margin-top: 0.4rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border);
}

.leave-btn {
    display: block;
    width: 100%;
    padding: 0.45rem 0.5rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: none;
    color: var(--danger);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.leave-btn:hover { background: var(--danger-bg); }
.leave-btn:focus-visible { outline: 2px solid var(--danger); outline-offset: 1px; }
.leave-btn[hidden] { display: none; }

.leave-confirm {
    padding: 0.55rem 0.6rem 0.6rem;
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    background: var(--danger-bg);
}

.leave-confirm[hidden] { display: none; }
.leave-confirm-title { margin: 0 0 0.2rem; font-size: 0.9rem; font-weight: 700; color: var(--text); }
.leave-confirm-text { margin: 0 0 0.55rem; font-size: 0.78rem; line-height: 1.4; color: var(--text-muted); }
.leave-confirm-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.leave-confirm-actions .btn { flex: 1 1 auto; }
.leave-confirm-actions .btn:disabled { opacity: 0.6; }

/* The lobby's "Leave": under the hint, as wide as the panels. */
.lobby-leave { margin-top: 0.75rem; }

.lobby-leave .leave-btn { text-align: center; }
