/* Base layout + nav chrome shell. Elm emits class names only; all visuals here.
   Real screens (Contacts/Conversation/Composer/Settings) arrive in 8.3+. */

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

html {
    -webkit-text-size-adjust: 100%;
    /* App-like: no rubber-band scroll past the edges. */
    overscroll-behavior: none;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior: none;
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* Mobile-first shell centered on wide viewports. */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg);
}

/* Sticky, blurred header (handoff: blur(14px) over 82% surface). */
.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
    /* Clear the status bar / notch in full-screen (home-screen) mode. */
    padding: max(12px, env(safe-area-inset-top)) var(--space-page) 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--hairline);
}

.app-header__title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-serif);
    font-size: var(--fs-app-title);
    font-weight: 500;
    color: var(--ink);
    margin: 0;
}

/* Logged-in username shown beside the app mark on the front page. */
.app-header__user {
    font-family: var(--font-sans);
    font-size: var(--fs-app-title);
    font-weight: 700;
    color: var(--ink);
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.lock-glyph {
    display: inline-flex;
    color: var(--muted);
}

/* The header lock is the app's anonymous mark — ink, not muted. */
.app-header__title .lock-glyph {
    color: var(--ink);
}

/* Round icon buttons (36px), neutral + accent variants. */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
    border-color: var(--muted);
}

/* Disabled icon buttons read as inactive (e.g. the composer's camera/photo
   placeholders before 8.6 wires capture). */
.icon-btn:disabled {
    color: var(--muted);
    opacity: 0.5;
    cursor: default;
}

.icon-btn--accent {
    border-color: transparent;
    background: var(--accent);
    color: var(--accent-contrast);
    box-shadow: var(--shadow-accent);
}

.icon-btn--accent:hover {
    background: var(--accent-hover);
    border-color: transparent;
}

/* Visible keyboard focus for every interactive control. */
.icon-btn:focus-visible,
.nav-link:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Main content column. */
.app-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-page);
}

/* Framed shell (Contacts): pinned to the viewport with the header fixed at the
   top and only .app-main scrolling internally. Uses position:fixed (not just
   height:100dvh) because .app-shell's min-height:100vh otherwise overflows the
   visible area on iOS — the page scrolls and takes the sticky header with it.
   Mirrors the .conversation frame. */
.app-shell--framed {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    min-height: 0;
    overflow: hidden;
}

/* On a roomy (desktop) viewport, let the content use more width than the phone
   column — the list/table screens and especially the messaging view benefit. */
@media (min-width: 768px) {
    .app-shell,
    .app-shell--framed {
        max-width: 720px;
    }

    /* The conversation + composer are their own fixed, centered frames. */
    .conversation,
    .composer {
        max-width: 860px;
    }
}

/* Scaffold placeholder page — replaced by real screens in 8.3+. */
.page-placeholder {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px 0;
}

.page-placeholder__title {
    font-family: var(--font-serif);
    font-size: var(--fs-subject);
    font-weight: 600;
    margin: 0;
}

.page-placeholder__note {
    color: var(--muted);
    margin: 0;
}

.section-label {
    font-size: var(--fs-section);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--ls-section);
    color: var(--muted);
}

/* Temporary router nav (removed once real screens land). */
.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-link {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-input);
    background: var(--surface);
    color: var(--ink);
    font-size: var(--fs-label);
}

.nav-link--active {
    border-color: var(--accent);
    color: var(--accent);
}

/* EXIT: the always-visible panic control in the app header and the conversation
   nav — leaves the messaging app for the game and clears this device's session. */
.exit-btn {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 13px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--accent-contrast);
    background: var(--accent);
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
}

.exit-btn:hover {
    background: var(--accent-hover);
}

.exit-btn:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}
