/*
 * One home per property
 *
 * This file owns purely visual styling: colors, fonts, opacity, cursors, and
 * layout that no test inspects (e.g. centering a tile's letter). Nothing here
 * is also set inline in Rust — each property lives in exactly one place.
 * See the corresponding note in src/theme.rs.
 */

:root {
    --bg: #210;
    --fg: #fed;
    --prompt-fg: #432;
    --prompt-bg: #dca;
    --border: black;
    --grid-border: #654;
    --font: Arial, Helvetica, sans-serif;
    --shadow: rgba(0, 0, 0, 0.5);
    --drag-border: #fbe;
    --tile-board-bg: #634918;
    --tile-rack-bg: #060;
    --tile-fg: #e9d9bc;
    --tile-border-color: #ccc;
    --tile-selected-border: #fc0;
    --tile-blank: #f80;
    --tile-subst: #f3c;
    --multiply-none: #999;
    --multiply-3w: #f66;
    --multiply-2w: #fcc;
    --multiply-3l: #77f;
    --multiply-2l: #6cf;
    --multiply-unknown-l: #6c4;
    --multiply-unknown-w: #270;
    --link: #8cf;
    --visited: #b9c;
    --players-turn: #3b3;
    --not-players-turn: #aaa;
    --notice-fg: #fed;
    --notice-bg: #840;
    --notice-border: #420;
    --error-fg: #f44;
    --reload-bg: #f00;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
}

/* Default link colors are unreadable on the brown background; these are a
 * starting point for manual iteration. */
a:link {
    color: var(--link);
}

a:visited {
    color: var(--visited);
}

/* Help page: plain default scheme, just margins and inter-block spacing. */
.help {
    margin: 20px;
}

/* Plain informational page (e.g. the email-verification landing page): default
 * scheme with page margins. */
.information {
    margin: 20px;
}

/* Failed-request text shown inline on a page (vs. the modal MessageDialog used in
 * the game). */
.error {
    color: var(--error-fg);
}

/* Start page: a vertical stack of primary actions; links styled to read like the
 * adjacent button. */
.start-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin: 16px 0;
}

.email-request {
    margin: 12px 0;
}

/* Tutorial videos wrap into a responsive grid of embeds. */
.tutorial-videos {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

/* New-game page: one row per player (delete button + name field) and the board-style
 * radios. */
.player-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 8px 0;
}

.player-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.radio-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.help p + p,
.help p + ul,
.help ul + p {
    margin-top: 20px;
}

/* Game layout. The .board box's width/height/overflow are set inline (reactive). */
.center-in-browser {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.game {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.controls {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    gap: 12px;
    padding: 8px;
}

.start-actions .button-link,
.control-buttons {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    gap: 8px;
}

.turn-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.play-controls {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    gap: 8px;
    position: relative;
}

.player {
    align-self: stretch;
    text-align: center;
}

.players-turn {
    color: var(--players-turn);
    font-weight: bold;
}

.not-players-turn {
    color: var(--not-players-turn);
}

.review-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-row {
    display: flex;
    flex-flow: row;
    align-items: center;
    gap: 6px;
}

.nav-row span {
    font-family: var(--font);
    font-size: 0.9rem;
    min-width: 3.5em;
    text-align: center;
}

.more-menu {
    position: relative;
}

.more-menu > summary {
    background: var(--prompt-bg);
    color: var(--prompt-fg);
    border: 2px solid var(--border);
    font-family: var(--font);
    font-weight: bold;
    font-size: 1rem;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 3px;
    list-style: none;
}

.more-menu > summary::-webkit-details-marker {
    display: none;
}

.more-menu > summary:hover {
    filter: brightness(1.2);
}

.more-menu-items {
    position: absolute;
    bottom: 100%;
    left: 0;
    z-index: 100;
    background: var(--prompt-bg);
    border: 2px solid var(--border);
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    padding: 4px;
    min-width: 200px;
    gap: 2px;
}

.start-actions .button-link,
.more-menu-items button,
.more-menu-items .menu-link {
    text-align: left;
    border: none;
    padding: 6px 10px;
    font-size: 0.9rem;
    border-radius: 2px;
}

/* Navigation items are anchors (real links, full-page navigation) styled to
 * match the menu's buttons. */
.start-actions .button-link,
.more-menu-items .menu-link {
    background: var(--prompt-bg);
    color: var(--prompt-fg);
    font-family: var(--font);
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
}

.more-menu-items .menu-link:hover {
    filter: brightness(1.2);
}

/* Cells: structural layout and cursor. Background is painted by the .mark
 * overlay (reactive); position: relative makes the cell the containing block
 * for that absolutely-positioned mark. */
[data-grid] {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
    border-radius: 6px;
}

.start-actions .button-link,
button {
    background: var(--prompt-bg);
    color: var(--prompt-fg);
    border: 2px solid var(--border);
    font-family: var(--font);
    font-weight: bold;
    font-size: 1rem;
    padding: 6px 16px;
    cursor: pointer;
    border-radius: 3px;
}

.start-actions .button-link:hover,
button:enabled:hover {
    filter: brightness(1.2);
}

button:enabled:active {
    filter: brightness(0.8);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

dialog {
    background: var(--prompt-bg);
    color: var(--prompt-fg);
    border: 2px solid var(--border);
}

dialog,
.notice {
    border-radius: 4px;
    padding: 16px 24px;
    font-family: var(--font);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

/* A non-interactive status box (e.g. "Loading...") floating in the screen
 * center. Shares the dialog's look but without the modal machinery. */
.notice {
    background: var(--notice-bg);
    color: var(--notice-fg);
    border: 8px solid var(--notice-border);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

/* Replaces the Reset button in the controls when an update poll finds the game or app out of date.
 * It just stands out (warn palette) to notify without obstructing; the player reloads when ready. */
.reload-button {
    background: var(--reload-bg);
    color: var(--notice-fg);
    border-color: var(--notice-border);
}

/* The loading/error placeholder is held hidden for a beat before fading in, so a fast load never
 * flashes the placeholder board or its message. `backwards` fill applies the hidden state only
 * during the delay; if animations are disabled it shows immediately rather than staying invisible.
 * */
.notice {
    animation: notice-appear 150ms ease-out 300ms backwards;
}

@keyframes notice-appear {
    from {
        opacity: 0;
    }
}

/* The confirm prompt may carry multiple lines (e.g. the play check result), joined with
 * newlines; render them as written rather than collapsing the whitespace. */
.confirm-prompt {
    white-space: pre-line;
}

/* Shared footer row of dialog buttons (confirm, message, swap). */
.dialog-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

/* Message dialog (scores / remaining bag tiles): a plain table whose columns
 * line up the cells supplied in MessageContent::rows. */
.message-table {
    border-collapse: collapse;
    user-select: none;
}

.message-table td {
    padding: 2px 8px;
    white-space: pre;
}

/* Swap dialog: a vertical stack of checkbox + tile rows. */
.swap-dialog {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.swap-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

/* The first heading in a dialog sits right against the top padding rather than
 * adding the browser's default heading margin on top of it. */
dialog > h1:first-child {
    margin-top: 0;
}

/* Preferences dialog: a vertical stack of checkbox + label rows. */
.preferences-dialog {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preference-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

/* Contact dialog: a stacked label and its email input. */
.contact-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.grid {
    border-radius: 8px;
}

/*
 * JXQZ tile — see src/tile.rs. Size-dependent px (box width/height, label and
 * score offsets, all font sizes) are set inline from theme.rs constants;
 * everything here is purely visual or a fixed, size-independent offset.
 */
.tile {
    position: relative;
    font-weight: bold;
    color: black;
    user-select: none;
    cursor: move;
    border: solid 1px var(--tile-border-color);
    border-radius: 4px;
    box-shadow:
        0 3px 1px -2px rgba(0, 0, 0, 0.2),
        0 2px 2px 0 rgba(0, 0, 0, 0.14),
        0 1px 5px 0 rgba(0, 0, 0, 0.12);
}

.tile-board {
    background: var(--tile-board-bg);
    color: var(--tile-fg);
}

.tile-rack {
    background: var(--tile-rack-bg);
    color: var(--tile-fg);
}

/* Selected and dragging are mutually exclusive; both replace the base border. */
.tile-selected {
    border: solid 6px var(--tile-selected-border);
}

.tile-dragging {
    border: solid 4px var(--drag-border);
}

.tile-board.tile-dragging {
    background: color-mix(in srgb, var(--tile-board-bg) 70%, transparent);
}

.tile-rack.tile-dragging {
    background: color-mix(in srgb, var(--tile-rack-bg) 70%, transparent);
}

.tile-label {
    position: absolute;
    line-height: 1;
}

.tile-label.blank {
    color: var(--tile-blank);
}

.tile-score {
    position: absolute;
    bottom: 0;
    text-align: right;
}

.tile-subst {
    position: absolute;
    top: 5px;
    right: 0;
    text-align: right;
    color: var(--tile-subst);
}

/*
 * Letter picker — see src/letter_picker.rs. Choices reuse .tile/.tile-board for
 * their look; these rules add the picker's fixed size and centered, score-free
 * layout (the live tile's inline size/font logic isn't needed here).
 */
.letter-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 360px;
}

.letter-pick {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    padding: 0;
    font-family: inherit;
    font-size: 32px;
    cursor: pointer;
}

/* Dev-only style-catalog table — see src/test_tile_styles.rs. */
.tile-catalog {
    user-select: none;
    color: black;
    background: var(--multiply-none);
}

.tile-catalog td {
    border: 1px solid var(--tile-border-color);
    padding: 10px;
    text-align: center;
}

.mark {
  user-select: none;
  border: 0;
  padding: 0px;
  margin: 0px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: absolute;
  border-radius: 6px;
  vertical-align: middle;
}
