/*
 * style.css - styling of the page.
 *
 * The visual grammar is that of Staunton, by the same author: gradient
 * background, white cards with rounded corners and drop shadow, coloured
 * buttons.
 *
 * Everything is here: the content security policy of the server allows
 * neither a style attribute nor an inline style sheet. A view is shown
 * or hidden with the hidden attribute, never with a style.
 */

:root {
    --primary:    #2c3e50;
    --info:       #3498db;
    --success:    #27ae60;
    --danger:     #e74c3c;
    --warning:    #f39c12;
    --border:     #bdc3c7;
    --text:       #2c3e50;
    --text-muted: #7f8c8d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/*
 * The hidden attribute must win over the display values set below, on
 * the containers and the buttons: hence one rule for all.
 */
[hidden] { display: none !important; }

body {
    min-height: 100vh;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

/* --------------------------------------------------------------- */
/* Header and footer                                                */
/* --------------------------------------------------------------- */

.page-header {
    max-width: 1080px;
    margin: 0 auto 12px;
    color: #fff;
    text-align: center;
    line-height: 1.2;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.page-header p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.page-footer {
    max-width: 1080px;
    margin: 14px auto 0;
    color: #fff;
    font-size: 0.85rem;
    text-align: center;
}

.page-footer a { color: #fff; }

/* --------------------------------------------------------------- */
/* Message for the player                                           */
/* --------------------------------------------------------------- */

.alert {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
    max-width: 1080px;
    margin: 0 auto 14px;
    padding: 12px 18px;
    border-radius: 8px;
    background: var(--warning);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    color: #fff;
    font-weight: 600;
}

/* The refusals of the server keep their line breaks. */
#alert-text { white-space: pre-line; }

/* --------------------------------------------------------------- */
/* General layout                                                   */
/* --------------------------------------------------------------- */

.container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
    justify-content: center;
    max-width: 1080px;
    margin: 0 auto;
}

.card {
    padding: 16px 20px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 360px;
    max-width: 100%;
}

.panel-wide {
    flex: 1 1 520px;
    width: auto;
    max-width: 700px;
}

/* --------------------------------------------------------------- */
/* Form                                                             */
/* --------------------------------------------------------------- */

.block h2 {
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.field { margin-top: 10px; }

.field label,
.field .label {
    display: block;
    margin-bottom: 3px;
    font-size: 0.88rem;
    font-weight: 600;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: inherit;
    font: inherit;
}

input[type="text"]:focus,
textarea:focus {
    border-color: var(--info);
    outline: none;
}

textarea {
    resize: vertical;
    font-family: "DejaVu Sans Mono", Consolas, monospace;
    font-size: 0.8rem;
}

#origin-pgn,
#origin-lichess { margin-top: 8px; }

.hint {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

details.hint summary {
    font-weight: 600;
    cursor: pointer;
}

.message {
    min-height: 1.2em;
    margin-top: 6px;
    font-size: 0.85rem;
}

.message.success { color: var(--success); }
.message.error   { color: var(--danger); }

.choice {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}

.choice-column { flex-direction: column; }

.choice label {
    display: flex;
    gap: 6px;
    align-items: baseline;
    font-weight: 400;
    cursor: pointer;
}

.warning {
    padding: 10px 12px;
    border-left: 4px solid var(--warning);
    border-radius: 4px;
    background: #fdf5e6;
    font-size: 0.88rem;
}

/* --------------------------------------------------------------- */
/* Buttons                                                          */
/* --------------------------------------------------------------- */

.btn {
    display: inline-block;
    padding: 8px 14px;
    border: 0;
    border-radius: 6px;
    color: #fff;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover    { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* A link that has nothing to give yet: the archive is on its way. */
.btn-waiting {
    opacity: 0.5;
    pointer-events: none;
}

.btn-info    { background: var(--info); }
.btn-success { background: var(--success); }
.btn-neutral { background: var(--text-muted); }

.btn-wide {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
}

/* A button that reads as a link, inside a sentence. */
.link {
    border: 0;
    background: none;
    color: var(--info);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

/* --------------------------------------------------------------- */
/* Wait                                                             */
/* --------------------------------------------------------------- */

/*
 * The bar is drawn here rather than left to the browser: the default
 * track of some of them is dark, and an empty bar then reads as a full
 * one.
 */
progress {
    display: block;
    width: 100%;
    height: 18px;
    margin-top: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #ecf0f1;
    appearance: none;
    -webkit-appearance: none;
}

progress::-webkit-progress-bar   { background: #ecf0f1; }
progress::-webkit-progress-value { background: var(--success); }
progress::-moz-progress-bar      { background: var(--success); }

#wait-message {
    font-family: "DejaVu Sans Mono", Consolas, monospace;
    font-size: 0.8rem;
}
