/* ═══════════════════════════════════════════════════════════
   Ali's Adventure – Stylesheet
   ═══════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ── */
:root {
    --bg:              #0f172a;
    --surface:         #1e293b;
    --border:          #334155;
    --text:            #f1f5f9;
    --muted:           #94a3b8;
    --blue:            #38bdf8;
    --green:           #34d399;
    --orange:          #fbbf24;
    --red:             #f87171;
    --gold:            #f59e0b;
    --selected-bg:     #065f46;
    --selected-border: #34d399;

    /* Notebook palette */
    --notebook-bg:     #fdf6e3;
    --notebook-line:   #d4c5a0;
    --notebook-text:   #2d1e0f;
    --notebook-accent: #8b4513;
}

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

/* ── BODY ── */
body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    padding: 8px;
}

/* ═══════════════════════════════════════════════════════════
   GAME CONTAINER
   ═══════════════════════════════════════════════════════════ */
#game-container {
    width: 100%;
    max-width: 980px;
    height: 96vh;
    max-height: 740px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 3px solid #475569;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 60px rgba(56, 189, 248, 0.08);
}

/* ═══════════════════════════════════════════════════════════
   SCENE AREA
   ═══════════════════════════════════════════════════════════ */
#visual-screen {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    transition: background-color 0.5s ease;
    overflow: hidden;
    min-height: 0;
}

/* Location background image */
#scene-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center bottom;
    opacity: 0;
    transition: opacity 0.5s ease;
    display: none;
}

#scene-canvas {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    pointer-events: none;
    overflow: hidden;
}

.scene-figure {
    font-size: 3.5rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-7px); }
}

/* ── Location header card ── */
#location-header {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(10, 18, 38, 0.94);
    padding: 10px 14px;
    border-radius: 10px;
    border-left: 4px solid var(--blue);
    max-width: 70%;
}

#location-title {
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    color: var(--blue);
    line-height: 1.2;
}

#location-subtitle {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 2px;
    font-style: italic;
    line-height: 1.3;
}

/* ── HUD (good deeds counter) ── */
#hud {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(10, 18, 38, 0.94);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.9rem;
    border: 2px solid var(--green);
    color: var(--green);
    display: flex;
    align-items: center;
    gap: 6px;
}

#deeds-count {
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
}

#deeds-count.pop { animation: pop 0.35s ease; }

@keyframes pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.7); color: #fbbf24; }
    100% { transform: scale(1); }
}

/* ═══════════════════════════════════════════════════════════
   GAME LOG
   ═══════════════════════════════════════════════════════════ */
#game-log {
    background: rgba(10, 18, 38, 0.96);
    padding: 12px 16px;
    min-height: 80px;
    max-height: 95px;
    overflow-y: auto;
    font-size: 0.9rem;
    border-top: 2px solid var(--border);
    line-height: 1.5;
}

#game-log.flash { animation: logflash 0.3s ease; }

@keyframes logflash {
    0%   { opacity: 0.3; }
    100% { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════
   SCUMM INTERFACE (verb bar + object lists)
   ═══════════════════════════════════════════════════════════ */
#scumm-interface {
    background: #0c1524;
    border-top: 3px solid #475569;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 10px;
    height: 210px;
    flex-shrink: 0;
}

/* ── Verb buttons ── */
#verb-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    align-content: start;
}

.verb-btn {
    background: #1e293b;
    border: 2px solid #334155;
    color: var(--text);
    border-radius: 8px;
    padding: 8px 4px;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    text-align: center;
    user-select: none;
    transition: background 0.15s, transform 0.1s;
}

.verb-btn:hover            { background: #273549; transform: translateY(-1px); }
.verb-btn.selected         { background: var(--selected-bg) !important; border-color: var(--selected-border) !important; color: var(--green); }
.verb-btn.focused          { outline: 2px solid var(--orange); outline-offset: 1px; background: #273549 !important; }

/* ── Object columns ── */
#object-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.scumm-col {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.scumm-col h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    font-weight: 800;
    flex-shrink: 0;
}

.scumm-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.obj-btn {
    background: #1e293b;
    border: 1px solid #334155;
    color: var(--text);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    text-align: left;
    user-select: none;
    transition: background 0.15s;
    width: 100%;
}

/* Notepad gets a warm gold tint to stand out */
.obj-btn.notepad-btn       { border-color: var(--gold); color: var(--gold); }
.obj-btn:hover             { background: #273549; }
.obj-btn.focused           { outline: 2px solid var(--orange); outline-offset: 1px; background: #273549 !important; }

.empty-hint {
    color: var(--muted);
    text-align: center;
    font-size: 0.78rem;
    padding: 12px 0;
}

/* ═══════════════════════════════════════════════════════════
   OVERLAYS (shared base)
   ═══════════════════════════════════════════════════════════ */
.overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(8, 14, 26, 0.96);
    justify-content: center;
    align-items: center;
    z-index: 20;
    padding: 20px;
}

/* ── Modal box (map + quiz) ── */
.modal-box {
    background: #1e293b;
    border: 2px solid var(--blue);
    padding: 24px 28px;
    border-radius: 14px;
    text-align: center;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 0 40px rgba(56, 189, 248, 0.15);
}

.modal-box h3 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.modal-box p { color: var(--muted); font-size: 0.88rem; line-height: 1.5; }

.modal-btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: none;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}

.modal-btn:hover       { opacity: 0.85; transform: translateY(-1px); }
.modal-btn-green       { background: var(--green); color: #0f172a; }
.modal-btn-dim         { background: #1e293b; border: 1px solid #475569; color: var(--muted); margin-top: 6px; }

/* ── Map overlay ── */
.map-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 14px 0 10px;
}

.map-section-label {
    grid-column: 1 / -1;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    margin-bottom: 2px;
}

.map-node {
    background: #0f172a;
    border: 1px solid #475569;
    color: var(--text);
    padding: 10px 8px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, transform 0.1s;
}

.map-node:not([disabled]):hover { background: #1e293b; transform: translateY(-1px); }
.map-node[disabled]             { opacity: 0.35; cursor: not-allowed; }
.map-node.current-loc           { border-color: var(--blue); color: var(--blue); }
.map-node.focused               { outline: 2px solid var(--orange); outline-offset: 1px; background: #273549 !important; }

/* ── Quiz overlay ── */
#quiz-input {
    width: 100%;
    padding: 10px 14px;
    margin: 14px 0 10px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: #0f172a;
    color: var(--text);
    font-size: 1rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

#quiz-input:focus   { border-color: var(--orange); }
#quiz-feedback      { min-height: 22px; font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; }
.quiz-ok            { color: var(--green); }
.quiz-fail          { color: var(--red); }

/* ═══════════════════════════════════════════════════════════
   NOTEPAD / JOURNAL OVERLAY
   ═══════════════════════════════════════════════════════════ */
#notebook-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(8, 14, 26, 0.96);
    justify-content: center;
    align-items: center;
    z-index: 20;
    padding: 20px;
}

.notebook-book {
    background: var(--notebook-bg);
    border-radius: 4px 12px 12px 4px;
    width: 100%;
    max-width: 500px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow:
        -6px 0 0 #c8a96e,
        -10px 0 0 #a0814d,
        0 8px 32px rgba(0, 0, 0, 0.6);
}

/* Leather spine */
.notebook-book::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 6px;
    background: linear-gradient(to right, #a0814d, #c8a96e);
    border-radius: 4px 0 0 4px;
}

.notebook-header {
    background: linear-gradient(135deg, #8b4513 0%, #a0522d 100%);
    color: #fdf6e3;
    padding: 14px 20px 14px 26px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.notebook-header-icon { font-size: 1.6rem; }

.notebook-header-text h3 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    color: #fdf6e3;
}

.notebook-header-text p {
    font-size: 0.75rem;
    color: #d4b896;
    margin-top: 1px;
}

/* Lined paper */
.notebook-entries {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 16px 26px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 27px,
        var(--notebook-line) 27px,
        var(--notebook-line) 28px
    );
    background-size: 100% 28px;
}

.notebook-entry {
    background: rgba(253, 246, 227, 0.85);
    border-left: 3px solid var(--notebook-accent);
    border-radius: 0 6px 6px 0;
    padding: 10px 12px;
    color: var(--notebook-text);
}

.entry-arabic {
    font-family: 'Amiri', serif;
    font-size: 1.5rem;
    text-align: right;
    direction: rtl;
    color: #5c3317;
    line-height: 1.4;
    margin-bottom: 4px;
}

.entry-transliteration {
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    color: #8b4513;
    margin-bottom: 2px;
}

.entry-translation {
    font-size: 0.85rem;
    font-weight: 700;
    color: #3d2b1a;
    margin-bottom: 6px;
}

.entry-divider {
    border: none;
    border-top: 1px dashed var(--notebook-line);
    margin: 6px 0;
}

.entry-context {
    font-size: 0.78rem;
    color: #7a5c3e;
    line-height: 1.4;
    font-style: italic;
}

.entry-badge {
    display: inline-block;
    background: #8b4513;
    color: #fdf6e3;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.notebook-empty {
    color: #a08060;
    font-style: italic;
    font-size: 0.9rem;
    text-align: center;
    padding: 30px 0;
}

.notebook-footer {
    padding: 10px 20px 10px 26px;
    background: #f0e6cc;
    border-top: 1px solid var(--notebook-line);
    flex-shrink: 0;
}

.notebook-close-btn {
    width: 100%;
    padding: 8px;
    background: #8b4513;
    color: #fdf6e3;
    border: none;
    border-radius: 6px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.88rem;
    cursor: pointer;
    transition: opacity 0.15s;
}

.notebook-close-btn:hover { opacity: 0.85; }

/* ═══════════════════════════════════════════════════════════
   ERROR SCREEN
   ═══════════════════════════════════════════════════════════ */
#error-screen {
    display: none;
    position: absolute;
    inset: 0;
    background: #0f172a;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 12px;
    z-index: 50;
    text-align: center;
    padding: 30px;
}

#error-screen h2 { color: var(--red); font-family: 'Fredoka One', cursive; font-size: 1.5rem; }
#error-screen p  { color: var(--muted); font-size: 0.9rem; max-width: 320px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    #scumm-interface           { grid-template-columns: 1fr; height: 260px; }
    #verb-grid                 { grid-template-columns: repeat(4, 1fr); }
}