/* =============================================================
   Dani's Porch
   Warm paper, system fonts, no webfonts, no keyframes.
   Everything here is either a colour token or a layout rule; the
   only motion is a 120ms transition on colour and opacity.
   ============================================================= */

:root {
    /* Light: warm paper and ink. */
    --paper: #faf6f0;
    --paper-raised: #fffdfa;
    --ink: #2e2a26;
    --ink-soft: #6d635a;
    --ink-faint: #9a8f83;
    --line: #e7ded2;
    --line-strong: #d8ccbc;
    --accent: #c2683f;
    --accent-strong: #a9552f;
    --accent-ink: #ffffff;
    --accent-wash: #f6e7dc;
    --danger: #a2503f;

    --radius: 14px;
    --radius-sm: 10px;
    --tap: 48px;

    --font-serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    /* Speaking ring colour, overridden per theme below. */
    --ring: var(--accent);
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Dark: warm charcoal, never blue-grey - the warmth is the point. */
        --paper: #1a1715;
        --paper-raised: #231f1b;
        --ink: #ece3d8;
        --ink-soft: #a99d8e;
        --ink-faint: #7c7266;
        --line: #332e28;
        --line-strong: #423b33;
        --accent: #e08b5c;
        --accent-strong: #eb9b6e;
        --accent-ink: #241a13;
        --accent-wash: #33261e;
        --danger: #d97a63;
    }
}

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

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    /* Respect the notch and the home indicator. */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
        env(safe-area-inset-left);
    /* A tap should never select label text on mobile. */
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

/* ------------------------------- shell ------------------------------- */

.door,
.room {
    max-width: 30rem;
    margin: 0 auto;
    padding: 1.5rem 1.25rem;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.door {
    justify-content: center;
}

.door-inner {
    /* Sits a little above centre; dead-centre reads as unfinished. */
    margin-bottom: 8vh;
}

/* ------------------------------- brand ------------------------------- */

.brand {
    text-align: center;
    margin: 0 0 2.25rem;
}

.brand-name {
    font-family: var(--font-serif);
    font-size: clamp(1.75rem, 7vw, 2.25rem);
    font-weight: 400;
    letter-spacing: 0.01em;
    margin: 0 0 0.35rem;
}

.brand-sub {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.95rem;
}

/* ----------------------------- presence ------------------------------ */

.presence {
    text-align: center;
    margin: -1.5rem 0 1.75rem;
    font-size: 0.92rem;
    color: var(--ink-soft);
    /* Reserved height, so the form never jumps when the count arrives. */
    min-height: 1.4em;
    transition: color 120ms ease;
}

.presence.is-busy {
    color: var(--accent);
}

/* ------------------------------- form -------------------------------- */

.door-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.field-label {
    font-size: 0.82rem;
    color: var(--ink-soft);
    letter-spacing: 0.02em;
}

.input {
    font: inherit;
    color: var(--ink);
    background: var(--paper-raised);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
    min-height: var(--tap);
    width: 100%;
    transition: border-color 120ms ease;
}

.input::placeholder {
    color: var(--ink-faint);
}

.input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Visible focus for keyboard users without a ring on every mouse click. */
.input:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ------------------------------ buttons ------------------------------ */

.btn {
    font: inherit;
    font-size: 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    min-height: var(--tap);
    padding: 0.7rem 1.1rem;
    cursor: pointer;
    background: transparent;
    color: var(--ink);
    /* A long press on a phone should not select the label like body text. */
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}

.btn-quiet {
    border-color: var(--line-strong);
    color: var(--ink-soft);
    background: var(--paper-raised);
    min-height: 40px;
    padding: 0.4rem 0.8rem;
    font-size: 0.88rem;
}

/* Hover only where there is a real pointer; on touch it sticks after a tap. */
@media (hover: hover) {
    /* A deeper accent, not --danger: "Come in" should not read as a warning. */
    .btn-primary:hover {
        background: var(--accent-strong);
    }
    .btn-quiet:hover {
        border-color: var(--accent);
        color: var(--accent);
    }
}

.btn:active {
    /* One honest press cue, no transform. */
    opacity: 0.85;
}

.door-note {
    margin: 1.25rem 0 0;
    text-align: center;
    color: var(--danger);
    font-size: 0.9rem;
}

/* ----------------------------- room head ----------------------------- */

.room-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--line);
}

.room-title {
    min-width: 0;
}

.room-name {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 400;
    margin: 0;
    /* A long room name must not push the copy button off screen. */
    overflow-wrap: anywhere;
}

.room-status {
    margin: 0.15rem 0 0;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.room-status.is-live {
    color: var(--accent);
}

.btn-copy {
    flex: none;
}

/* ------------------------------ people ------------------------------- */

.people {
    list-style: none;
    margin: 0;
    padding: 0.75rem 0 0;
    /* Takes the slack so the controls stay pinned to the bottom. */
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    overflow-y: auto;
    /* Two or three people look stranded at the top of a tall phone screen.
       `safe` keeps the first row reachable if the list ever does overflow;
       browsers without it fall back to the top, which is also fine. */
    justify-content: safe center;
}

.person {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.25rem;
}

.avatar {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-serif);
    font-size: 1.15rem;
    color: var(--accent-ink);
    /* Hue is set inline from a hash of the name. */
    background: var(--avatar, var(--accent));
    /* The ring lives on the avatar so the row itself never reflows. */
    box-shadow: 0 0 0 0 var(--paper), 0 0 0 0 var(--ring);
    transition: box-shadow 120ms ease, opacity 120ms ease;
}

/* Two rings with a paper-coloured gap between them. Without the gap the ring
   disappears whenever a name hashes to a hue close to the accent. */
.person.is-speaking .avatar {
    box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ring);
}

.person.is-muted .avatar {
    opacity: 0.45;
}

.person-body {
    min-width: 0;
    flex: 1;
}

.person-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.person-meta {
    display: block;
    font-size: 0.82rem;
    color: var(--ink-soft);
}

.person-you .person-name::after {
    content: ' (you)';
    color: var(--ink-faint);
    font-size: 0.85rem;
}

.people-empty {
    color: var(--ink-soft);
    font-size: 0.92rem;
    padding: 1.25rem 0.25rem;
}

/* ----------------------------- controls ------------------------------ */

.unblock {
    margin: 0 0 0.75rem;
    width: 100%;
}

.controls {
    display: flex;
    gap: 0.6rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.btn-mic {
    flex: 1;
    background: var(--accent-wash);
    border-color: var(--line-strong);
    font-weight: 600;
    min-height: 56px;
}

/* Pressed = muted. The loud state is the quiet-looking one, deliberately:
   you should be able to tell at a glance that you are off. */
.btn-mic[aria-pressed='true'] {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
}

/* Sits between Mute and Leave: a room action, not a personal one, but it
   belongs on the bottom bar where a thumb already is. */
.btn-lock {
    flex: none;
    color: var(--ink-soft);
    border-color: var(--line-strong);
    min-height: 56px;
}

/* Locked is a state, not an action, so it reads as filled rather than outlined. */
.btn-lock[aria-pressed='true'] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.btn-leave {
    flex: none;
    color: var(--danger);
    border-color: var(--line-strong);
    min-height: 56px;
}

@media (hover: hover) {
    .btn-leave:hover {
        background: var(--danger);
        color: var(--paper-raised);
        border-color: var(--danger);
    }
    .btn-lock:hover {
        border-color: var(--accent);
        color: var(--accent);
    }
    .btn-lock[aria-pressed='true']:hover {
        background: var(--accent-strong);
        border-color: var(--accent-strong);
        color: var(--accent-ink);
    }
}

/* Wider screens get a little more air, nothing more. */
@media (min-width: 40rem) {
    .door,
    .room {
        padding: 2.5rem 1.5rem;
    }
}

/* Someone who asked for less motion gets none at all. */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
