/* app.css — Baanabus mobile-first styles
 * Only contains styles actively in use. Legacy CSS kept in styles.css for reference.
 */

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #fff;
    color: hsl(210, 100%, 20%);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* Canvas scene pages lock scroll via JS adding this class */
body.scene-view { overflow: hidden; }

/* === Time-of-day tint overlay === */
#scene-tint {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    /* 60s transition gives continuous-looking colour shift as the minute timer fires */
    transition: background-color 60s linear;
}

/* === Typography === */
h1, h2, h3 { color: hsl(210, 100%, 20%); font-weight: 400; margin-top: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
p  { margin: 0.5rem 0; line-height: 1.5; }

.muted    { color: #888; font-size: 0.9em; }
.hint     { color: #aaa; font-size: 0.82em; }
.highlight { font-weight: 700; color: hsl(210, 100%, 30%); }
.completed { color: #aaa; font-weight: 300; text-decoration: line-through; }
.hidden   { display: none !important; }

/* === Navbar === */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 200;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.navbar li a {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 12px;
    height: 44px;
    text-decoration: none;
    color: hsl(210, 100%, 20%);
    font-size: 0.85em;
    white-space: nowrap;
    transition: color 0.2s;
}

.navbar li a:hover { color: hsl(210, 100%, 45%); }

/* Mobile: hide nav labels, show emojis only */
@media (max-width: 600px) {
    .navbar li a { padding: 0 9px; font-size: 1.2em; }
    .navbar li a .nav-text { display: none; }
}

/* === Buttons === */
.btn,
button.btn,
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    min-height: 44px;
    background: hsl(210, 100%, 30%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover  { background: hsl(210, 100%, 40%); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: transparent;
    color: hsl(210, 100%, 30%);
    border: 1.5px solid hsl(210, 100%, 30%);
}
.btn-secondary:hover { background: hsl(210, 100%, 96%); }

/* === Form elements === */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    min-height: 44px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    color: hsl(210, 100%, 20%);
    background: #fff;
    appearance: none;
    -webkit-appearance: none;
}

input:focus, textarea:focus, select:focus {
    border-color: hsl(210, 100%, 40%);
    outline: none;
    box-shadow: 0 0 0 3px hsla(210, 100%, 40%, 0.15);
}

/* === Layout: Container === */
.container {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: 1rem;
}

/* On pages with a navbar, push content below it */
.page-content {
    padding-top: 52px;
}

/* === Settings tabs === */
.settings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 1rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 0;
}
.settings-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 6px 12px;
    font-size: 0.9em;
    color: #888;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: color 0.15s;
}
.settings-tab:hover { color: #444; }
.settings-tab.active { color: #5c6bc0; border-bottom-color: #5c6bc0; font-weight: 600; }
.settings-panel { padding-top: 0.25rem; }
.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 0.9em;
    cursor: pointer;
    gap: 1rem;
}
.settings-toggle-row:last-child { border-bottom: none; }
.settings-toggle-row input[type=checkbox] { flex-shrink: 0; width: 18px; height: 18px; cursor: pointer; }

/* === Card === */
.card {
    background: #fff;
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    margin-bottom: 1rem;
}

/* === Overlay (full-screen modal layer) === */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 100;
}

.overlay-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 14px;
    padding: 1.5rem;
    width: 88%;
    max-width: 760px;
    max-height: 82vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile: bottom sheet */
@media (max-width: 640px) {
    .overlay-content {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-height: 88vh;
        border-radius: 18px 18px 0 0;
        padding: 1rem 1rem 1.5rem;
    }
}

/* Close button (works inside both overlay and speechBubble) */
.close-button {
    position: absolute;
    top: 10px;
    right: 16px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    background: none;
    border: none;
    padding: 4px;
    -webkit-tap-highlight-color: transparent;
}
.close-button:hover { color: #000; }

/* === Speech Bubble === */
.speechBubble {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 80;
    pointer-events: none;
}

.speechBubble-content {
    position: absolute;
    background: #fff;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    max-width: min(320px, 85vw);
    pointer-events: auto;
    /* Default position: right of centre, adjusted for avatar */
    top: 50%;
    left: 60%;
    transform: translate(-50%, -50%);
}

@media (max-width: 640px) {
    .speechBubble-content {
        top: 40%;
        bottom: auto;
        left: 55%;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 90vw;
        max-height: 45vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #triage-title {
        min-height: 72px;
    }
}

/* === Status / feedback text === */
#authStatus, .auth-status, #status {
    min-height: 1.4em;
    margin-top: 0.5rem;
    font-size: 0.9em;
}

/* === Progress bar === */
.progress-container {
    width: 100%;
    background: #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    height: 18px;
    margin: 8px 0;
}
.progress-bar {
    height: 100%;
    background: #4caf50;
    transition: width 0.4s ease;
}

/* === Task items === */
.task-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid hsl(210, 100%, 80%);
    border-radius: 6px;
    padding: 10px 12px;
    margin: 4px 0;
    gap: 8px;
}

.task-info-box {
    border: 1px solid hsl(210, 100%, 80%);
    border-radius: 6px;
    padding: 10px 12px;
    margin: 4px 0;
    font-size: 0.95em;
    overflow: hidden;
}

.task-checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid hsl(210, 100%, 30%);
    border-radius: 4px;
    cursor: pointer;
    accent-color: hsl(210, 100%, 30%);
    vertical-align: middle;
}

.left-content  { display: inline; }
.right-content { float: right; display: flex; gap: 6px; }

/* === Action links === */
.edit-link,
.delete-link,
.action-button,
.choice-button {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    min-height: 36px;
    background: hsl(210, 100%, 30%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85em;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}
.edit-link:hover, .action-button:hover, .choice-button:hover {
    background: hsl(210, 100%, 40%);
}
.delete-link { background: #dc3545; }
.delete-link:hover { background: #c0392b; }

/* === Scene canvas === */
#sceneCanvas, #calCanvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
}

/* === Calendar scene nav bar === */
#cal-nav {
    position: fixed;
    top: 44px;
    left: 0;
    width: 100%;
    height: 44px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    z-index: 150;
}
#cal-nav h2 {
    font-size: 1rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.01em;
}
#cal-nav button {
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    color: hsl(210, 100%, 30%);
    cursor: pointer;
    padding: 0 10px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Star pip animation === */
@keyframes fly-to-bar {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  15%  { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(0.1); opacity: 0; }
}
.star-pip {
  position: fixed;
  pointer-events: none;
  font-size: 1.6rem;
  line-height: 1;
  color: #f5a623;
  text-shadow: 0 0 8px rgba(245, 166, 35, 0.9);
  z-index: 999;
  animation: fly-to-bar 0.75s cubic-bezier(0.4, 0, 0.8, 0.3) forwards;
}

/* === Progress bar (scene overlay) === */
.scene-progress {
    position: fixed;
    bottom: 1.4rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(260px, 78vw);
    height: 6px;
    background: rgba(180, 160, 130, 0.35);
    border-radius: 3px;
    display: none;
    z-index: 50;
    pointer-events: none;
}
body.scene-view .scene-progress { display: block; }

#scene-total-pips {
    position: fixed;
    bottom: 0.45rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65em;
    color: rgba(255, 255, 255, 0.55);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    display: none;
    z-index: 50;
    white-space: nowrap;
    letter-spacing: 0.03em;
}
body.scene-view #scene-total-pips { display: block; }

/* Clock on right wall (desktop scene only) */
#scene-clock {
    position: fixed;
    right: 3vw;
    top: 38%;
    transform: translateY(-50%);
    font-size: clamp(2rem, 4vw, 3.8rem);
    font-weight: 200;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 2px 12px rgba(0,0,0,0.9), 0 0 30px rgba(0,0,0,0.6);
    pointer-events: none;
    display: none;
    z-index: 50;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
/* Only show on desktop scene view */
@media (min-width: 641px) {
    body.scene-view #scene-clock  { display: block; }
}

/* Navbar context dropdowns — desktop only */
.nav-checkin { display: none; align-items: center; padding: 0 4px; }
@media (min-width: 601px) {
    .nav-checkin { display: flex; }
}
.nav-checkin-select {
    background: transparent;
    border: none;
    color: hsl(210, 40%, 30%);
    font-size: 0.82em;
    padding: 4px 2px;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    max-width: 7em;
}
.nav-checkin-select:hover  { color: hsl(210, 100%, 45%); }
.nav-checkin-select:focus  { color: hsl(210, 100%, 45%); }
.night-mode .nav-checkin-select { color: #b8b8d8; }
#scene-energy {
    display: none;
    position: fixed;
    right: 3vw;
    top: calc(38% + clamp(1.2rem, 2.2vw, 2.2rem));
    font-size: clamp(0.6rem, 0.9vw, 0.8rem);
    color: rgba(255,255,255,0.5);
    font-family: 'Georgia', serif;
    letter-spacing: 0.05em;
    text-align: right;
}

/* Floating scene mode buttons (Reset, Tired) */
.scene-mode-btn {
    position: fixed;
    bottom: 3.2rem;
    background: rgba(60, 60, 80, 0.55);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 1.1em;
    cursor: pointer;
    z-index: 50;
    display: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.just-games-btn::after {
    content: ' Just games';
    font-size: 0.78em;
    opacity: 0.85;
}
body.scene-view .scene-mode-btn { display: inline-flex; align-items: center; }
.scene-mode-btn:hover { background: rgba(80, 60, 100, 0.75); }
#reset-btn { left: 50%; transform: translateX(-50%); }
#reset-btn.active { background: rgba(80,60,20,0.82); border-color: rgba(255,200,100,0.4); }
.scene-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #f5a623, #f7c96a);
    border-radius: 3px;
    transition: width 0.5s ease;
    min-width: 0;
}

/* === Onboarding wizard === */
#setup-wizard { text-align: center; padding: 0.5rem 0 1rem; }

.wiz-progress {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 1.75rem;
}
.wiz-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ddd;
    transition: background 0.3s;
}
.wiz-dot.active { background: hsl(210, 100%, 40%); }

.wiz-sheep { font-size: 3.5rem; margin-bottom: 0.5rem; line-height: 1; }

.wiz-choices {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 1rem 0 0.5rem;
}
.wiz-choice.wiz-chosen {
    outline: 3px solid hsl(210, 100%, 40%);
    outline-offset: 2px;
}

/* Tic-tac-toe board */
#ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 76px);
    gap: 8px;
    justify-content: center;
    margin: 1rem auto 0.75rem;
}
.ttt-cell {
    width: 76px;
    height: 76px;
    font-size: 2rem;
    background: hsl(210, 30%, 97%);
    border: 2px solid hsl(210, 20%, 85%);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.1s;
    font-family: inherit;
}
.ttt-cell:hover:not(:disabled):not(.ttt-x):not(.ttt-o) {
    background: hsl(210, 60%, 93%);
}
.ttt-cell.ttt-x { color: hsl(210, 100%, 35%); font-weight: 700; }
.ttt-cell.ttt-o { color: hsl(0, 65%, 55%); font-weight: 700; }
.ttt-cell:disabled { cursor: default; }

/* === Utility === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* === Night mode (post-sunset) === */

.night-mode .navbar {
    background: rgba(16, 16, 42, 0.96);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}
.night-mode .navbar li a { color: #b8b8d8; }
.night-mode .navbar li a:hover { color: #e8e8ff; }

.night-mode .overlay-content,
.night-mode .speechBubble-content {
    background: #1a1a2e;
    color: #e0e0f0;
}

.night-mode .overlay-content h1,
.night-mode .overlay-content h2,
.night-mode .overlay-content h3,
.night-mode .speechBubble-content h1,
.night-mode .speechBubble-content h2,
.night-mode .speechBubble-content h3 { color: #e8e8ff; }

.night-mode .overlay-content p,
.night-mode .speechBubble-content p { color: #d0d0e8; }

.night-mode .overlay-content .muted,
.night-mode .speechBubble-content .muted { color: #8888aa; }

.night-mode .overlay-content .hint,
.night-mode .speechBubble-content .hint { color: #66667e; }

.night-mode .overlay-content .highlight,
.night-mode .speechBubble-content .highlight { color: #90b8ff; }

.night-mode .overlay-content .card,
.night-mode .speechBubble-content .card {
    background: #22223c;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.night-mode .overlay-content .task-container,
.night-mode .speechBubble-content .task-container {
    border-color: rgba(120, 120, 200, 0.25);
}

.night-mode .overlay-content .task-info-box,
.night-mode .speechBubble-content .task-info-box {
    border-color: rgba(120, 120, 200, 0.25);
}

.night-mode .overlay-content .task-checkbox,
.night-mode .speechBubble-content .task-checkbox {
    border-color: #6060a0;
}

.night-mode .overlay-content input[type="text"],
.night-mode .overlay-content input[type="password"],
.night-mode .overlay-content input[type="email"],
.night-mode .overlay-content input[type="search"],
.night-mode .overlay-content textarea,
.night-mode .overlay-content select {
    background: #22223c;
    color: #e0e0f0;
    border-color: rgba(255, 255, 255, 0.15);
}

.night-mode .overlay-content input:focus,
.night-mode .overlay-content textarea:focus,
.night-mode .overlay-content select:focus {
    border-color: #6080d0;
    box-shadow: 0 0 0 3px rgba(96, 128, 208, 0.20);
}

.night-mode .overlay-content .btn-secondary,
.night-mode .speechBubble-content .btn-secondary {
    color: #90b0ff;
    border-color: #90b0ff;
}
.night-mode .overlay-content .btn-secondary:hover,
.night-mode .speechBubble-content .btn-secondary:hover {
    background: rgba(144, 176, 255, 0.10);
}

.night-mode .close-button { color: #8080a8; }
.night-mode .close-button:hover { color: #e0e0ff; }

.selected { outline: 3px solid hsl(210, 100%, 30%); }
