/*
 * web/static/style.css — DAVE Web Frontend Stylesheet
 *
 * Developed with the assistance of Claude (model: claude-sonnet-4-6, Anthropic)
 *
 * Parchment / sepia aesthetic. All colour values are defined as variables at
 * the top so that the palette can be adjusted in one place.
 *
 * Palette:
 *   --parchment:   #f4e4c1  — main background
 *   --parchment-dark: #e8d4a8 — card / field backgrounds
 *   --ink:         #3d2b1f  — primary text
 *   --ink-light:   #5c4033  — secondary text
 *   --gold:        #8b6914  — headings and accents
 *   --sepia:       #c4a35a  — borders and highlights
 *   --sepia-light: #d4b87a  — hover states
 *   --error:       #8b2020  — error messages (dark red on parchment)
 */

/* =========================================================================
   CSS custom properties (design tokens)
   ========================================================================= */

:root {
    --parchment:      #f4e4c1;
    --parchment-dark: #e8d4a8;
    --parchment-mid:  #eeddb5;
    --ink:            #3d2b1f;
    --ink-light:      #5c4033;
    --gold:           #8b6914;
    --sepia:          #c4a35a;
    --sepia-light:    #d4b87a;
    --error:          #8b2020;
    --success:        #2a5c1a;

    --font-body:  Georgia, "Times New Roman", serif;
    --font-mono:  "Courier New", Courier, monospace;

    --radius:     4px;
    --shadow:     0 2px 8px rgba(61, 43, 31, 0.18);
    --shadow-lg:  0 4px 20px rgba(61, 43, 31, 0.25);
}


/* =========================================================================
   Reset and base
   ========================================================================= */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background-color: var(--parchment);
    color: var(--ink);
    font-family: var(--font-body);
    line-height: 1.65;
    min-height: 100vh;
}

/* Subtle parchment texture: two overlapping radial gradients simulate
   aged paper without requiring an image asset. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(196, 163, 90, 0.10) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 70%, rgba(139, 105, 20, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

main, header, footer, nav {
    position: relative;
    z-index: 1;
}


/* =========================================================================
   Typography
   ========================================================================= */

h1, h2, h3, h4 {
    color: var(--gold);
    font-family: var(--font-body);
    font-weight: bold;
    line-height: 1.3;
}

h1 { font-size: 2rem;   margin-bottom: 0.5rem; }
h2 { font-size: 1.5rem; margin-bottom: 0.4rem; }
h3 { font-size: 1.2rem; margin-bottom: 0.3rem; }

p { margin-bottom: 0.9rem; }
p:last-child { margin-bottom: 0; }

a {
    color: var(--gold);
    text-decoration: underline;
}

a:hover {
    color: var(--sepia);
}

em { font-style: italic; }
strong { font-weight: bold; color: var(--ink); }

hr {
    border: none;
    border-top: 1px solid var(--sepia);
    margin: 1.5rem 0;
    opacity: 0.6;
}


/* =========================================================================
   Page layout
   ========================================================================= */

.page-wrapper {
    max-width: 760px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.page-wrapper--wide {
    max-width: 960px;
}

/* Centered single-column layout for auth pages (login, register). */
.page-wrapper--narrow {
    max-width: 440px;
}


/* =========================================================================
   Header
   ========================================================================= */

.site-header {
    border-bottom: 2px solid var(--sepia);
    padding: 1rem 0;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.site-header__title {
    font-size: 1.6rem;
    color: var(--gold);
    letter-spacing: 0.04em;
    text-decoration: none;
}

.site-header__title:hover {
    color: var(--sepia);
}

.site-header__nav {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.site-header__nav a {
    color: var(--ink-light);
    text-decoration: none;
}

.site-header__nav a:hover {
    color: var(--gold);
    text-decoration: underline;
}


/* =========================================================================
   Cards and panels
   ========================================================================= */

.card {
    background: var(--parchment-mid);
    border: 1px solid var(--sepia);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.25rem;
}

.card--compact {
    padding: 1rem 1.25rem;
}

.card__title {
    font-size: 1.15rem;
    color: var(--gold);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--sepia);
}


/* =========================================================================
   Forms
   ========================================================================= */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--ink-light);
    margin-bottom: 0.3rem;
    font-style: italic;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--parchment-dark);
    border: 1px solid var(--sepia);
    border-radius: var(--radius);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(139, 105, 20, 0.20);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--ink-light);
    margin-top: 0.2rem;
    font-style: italic;
}


/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--sepia);
    border-radius: var(--radius);
    background: var(--parchment-dark);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--sepia-light);
    border-color: var(--gold);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.btn:active {
    background: var(--sepia);
}

.btn--primary {
    background: var(--gold);
    color: var(--parchment);
    border-color: var(--gold);
    font-weight: bold;
}

.btn--primary:hover {
    background: #7a5a10;
    border-color: #7a5a10;
    color: var(--parchment);
}

.btn--danger {
    background: var(--parchment-dark);
    color: var(--error);
    border-color: var(--error);
}

.btn--danger:hover {
    background: var(--error);
    color: var(--parchment);
}

.btn--sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
}

.btn-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}


/* =========================================================================
   Flash messages
   ========================================================================= */

.flash-messages {
    list-style: none;
    margin-bottom: 1rem;
}

.flash {
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    border: 1px solid;
}

.flash--error {
    background: #f9eded;
    color: var(--error);
    border-color: var(--error);
}

.flash--info {
    background: var(--parchment-mid);
    color: var(--ink);
    border-color: var(--sepia);
}

.flash--success {
    background: #edf4eb;
    color: var(--success);
    border-color: var(--success);
}


/* =========================================================================
   Budget indicator
   ========================================================================= */

.budget-bar {
    margin-top: 0.5rem;
}

.budget-bar__label {
    font-size: 0.8rem;
    color: var(--ink-light);
    margin-bottom: 0.2rem;
}

.budget-bar__track {
    height: 6px;
    background: var(--parchment-dark);
    border: 1px solid var(--sepia);
    border-radius: 3px;
    overflow: hidden;
}

.budget-bar__fill {
    height: 100%;
    background: var(--gold);
    transition: width 0.4s ease;
}

.budget-bar__fill--warning {
    background: #b8860b;
}

.budget-bar__fill--critical {
    background: var(--error);
}


/* =========================================================================
   Game session terminal
   ========================================================================= */

.game-terminal {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 12rem);
    min-height: 400px;
}

.game-terminal__output {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    background: var(--parchment-mid);
    border: 1px solid var(--sepia);
    border-radius: var(--radius) var(--radius) 0 0;
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.75;
}

.game-terminal__output .turn {
    margin-bottom: 1.25rem;
}

.game-terminal__output .turn__player {
    color: var(--ink-light);
    font-style: italic;
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}

.game-terminal__output .turn__prose {
    color: var(--ink);
    white-space: pre-wrap;
}

.game-terminal__input-row {
    display: flex;
    gap: 0;
    border: 1px solid var(--sepia);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}

.game-terminal__input {
    flex: 1;
    padding: 0.6rem 0.9rem;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    background: var(--parchment-dark);
    border: none;
    color: var(--ink);
    outline: none;
}

.game-terminal__input:focus {
    background: #f0dba5;
}

.game-terminal__submit {
    padding: 0.6rem 1.1rem;
    background: var(--gold);
    color: var(--parchment);
    border: none;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.game-terminal__submit:hover {
    background: #7a5a10;
}

.game-terminal__submit:disabled {
    background: var(--sepia);
    cursor: wait;
}


/* =========================================================================
   Module selector (lobby)
   ========================================================================= */

.module-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.module-card {
    display: block;
    padding: 1rem 1.25rem;
    background: var(--parchment-dark);
    border: 1px solid var(--sepia);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    text-align: left;
    width: 100%;
    font-family: var(--font-body);
    color: var(--ink);
    font-size: 1rem;
}

.module-card:hover {
    background: var(--sepia-light);
    border-color: var(--gold);
    box-shadow: var(--shadow);
}

.module-card__name {
    font-size: 1.05rem;
    font-weight: bold;
    color: var(--gold);
}

.module-card__desc {
    font-size: 0.85rem;
    color: var(--ink-light);
    margin-top: 0.2rem;
    font-style: italic;
}


/* =========================================================================
   Contact / slots-full page
   ========================================================================= */

.contact-panel {
    text-align: center;
    padding: 2rem 1.5rem;
}

.contact-panel p {
    max-width: 440px;
    margin: 0 auto 1.25rem;
    font-size: 1.05rem;
    color: var(--ink-light);
}

.contact-panel .btn {
    margin-top: 0.5rem;
}


/* =========================================================================
   Footer
   ========================================================================= */

.site-footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--sepia);
    font-size: 0.8rem;
    color: var(--ink-light);
    text-align: center;
    font-style: italic;
}


/* =========================================================================
   Thinking indicator — animated ellipsis shown while the engine is working
   ========================================================================= */

.thinking {
    display: none;          /* hidden by default; JS sets display:block */
    padding: 0.4rem 0;
    color: var(--ink-light);
    font-style: italic;
    font-size: 0.9rem;
}

.thinking__dots::after {
    content: "";
    display: inline-block;
    animation: ellipsis 1.4s steps(4, end) infinite;
    width: 1.5em;           /* reserve space so layout doesn't shift */
    text-align: left;
}

@keyframes ellipsis {
    0%   { content: "";    }
    25%  { content: ".";   }
    50%  { content: "..";  }
    75%  { content: "..."; }
}


/* =========================================================================
   Responsive — narrow screens
   ========================================================================= */

@media (max-width: 520px) {
    h1 { font-size: 1.5rem; }
    .card { padding: 1rem 1rem; }
    .game-terminal { height: calc(100vh - 9rem); }
}
