/* North Wales Mark MAP — PWA Styles */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary:       #2c5f8a;
    --primary-dark:  #1e4466;
    --primary-light: #e8f0f7;
    --secondary:     #6c3483;
    --success:       #27ae60;
    --warning:       #e67e22;
    --danger:        #e74c3c;
    --text:          #333333;
    --text-muted:    #777777;
    --border:        #dddddd;
    --bg:            #f4f6f8;
    --white:         #ffffff;
    --radius:        8px;
    --shadow:        0 2px 8px rgba(0,0,0,0.08);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    background: var(--white);
}

header {
    background: var(--primary);
    color: var(--white);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

header .header-actions a,
header .header-actions button {
    color: var(--white);
    background: none;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    margin-left: 1rem;
    opacity: 0.9;
}

header .header-actions a:hover,
header .header-actions button:hover {
    opacity: 1;
    text-decoration: underline;
}

main {
    flex: 1;
    padding: 1.25rem;
}

/* ── Bottom nav ── */
.bottom-nav {
    display: flex;
    background: var(--white);
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
}

.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.7rem 0.5rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    gap: 0.2rem;
    transition: color 0.15s;
}

.bottom-nav a.active,
.bottom-nav a:hover {
    color: var(--primary);
}

.bottom-nav .nav-icon {
    font-size: 1.4rem;
    line-height: 1;
}

/* ── Cards ── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

/* ── Forms ── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    color: var(--text);
    background: var(--white);
    appearance: none;
    -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44,95,138,0.15);
}

/* Checkboxes must not inherit the full-width, appearance:none text-input
   styling above (which rendered them as a wide, un-tickable empty box).
   Restore native rendering; higher specificity means this wins. */
.form-group input[type="checkbox"] {
    width: auto;
    appearance: auto;
    -webkit-appearance: auto;
    padding: 0;
    margin: 0 0.5rem 0 0;
    border: 0;
    box-shadow: none;
    vertical-align: middle;
    cursor: pointer;
}

.form-group .error {
    font-size: 0.82rem;
    color: var(--danger);
    margin-top: 0.3rem;
}

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s, opacity 0.15s;
    width: 100%;
}

.btn-primary  { background: var(--primary);   color: var(--white); }
.btn-success  { background: var(--success);   color: var(--white); }
.btn-danger   { background: var(--danger);    color: var(--white); }
.btn-outline  {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-primary:hover  { background: var(--primary-dark); }
.btn-success:hover  { background: #1e8449; }
.btn-danger:hover   { background: #c0392b; }
.btn-outline:hover  { background: var(--primary-light); }

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Alerts ── */
.alert {
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alert-success { background: #d5f5e3; color: #1e8449; }
.alert-error   { background: #fde8e8; color: #c0392b; }
.alert-info    { background: var(--primary-light); color: var(--primary); }
.alert-warning { background: #fef3e2; color: #ca6f1e; }

/* ── Leaderboard ── */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th {
    text-align: left;
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.leaderboard-table td {
    padding: 0.7rem 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.leaderboard-table tr:last-child td { border-bottom: none; }

.leaderboard-table .rank {
    font-weight: bold;
    color: var(--text-muted);
    width: 2rem;
}

.leaderboard-table .rank-1 { color: #f1c40f; }
.leaderboard-table .rank-2 { color: #95a5a6; }
.leaderboard-table .rank-3 { color: #cd6133; }

.leaderboard-table .score {
    font-weight: bold;
    color: var(--primary);
    text-align: right;
}

/* ── Visit history ── */
.visit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.visit-item:last-child { border-bottom: none; }

.visit-item .lodge-name { font-weight: 500; }

.visit-item .lodge-type {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
}

.type-mark { background: #e8f0f7; color: var(--primary); }
.type-ram  { background: #f3e8f7; color: var(--secondary); }

.visit-item .visit-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Score display ── */
.score-display {
    text-align: center;
    padding: 1.5rem;
}

.score-display .big-number {
    font-size: 4rem;
    font-weight: bold;
    color: var(--primary);
    line-height: 1;
}

.score-display .score-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ── Loading spinner ── */
.spinner {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.spinner::after {
    content: '';
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: 0.95rem; }

/* ── Utilities ── */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }