/* Toilet.Chat: you sit inside the stall. The controls take their colours from the door style,
   main.js overrides these variables with the chrome colours of the open door's style. */
:root {
    --partition: #3b4448;
    --partition-dark: #30383b;
    --text: #eef2f3;
    --text-dim: #b5c1c4;
    --accent: #f0b43c;
    --accent-ink: #2e2104;
    --stall: #b9c6ca;
    --stall-ink: #2a3336;
    --paper: #f4f1ea;

    --f-display: "Barlow Condensed", "Arial Narrow", sans-serif;
    --f-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    background: var(--partition-dark);
    color: var(--text);
    font-family: var(--f-body);
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

[hidden] { display: none !important; }

#app {
    height: 100%;
    max-width: 520px;
    margin: 0 auto;
    background: var(--partition);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
}

button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- plaque ---------- */
.plaque {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 10px 16px;
}
.plaque .name { flex: 1; min-width: 0; }
.plaque h1 {
    margin: 0;
    font-family: var(--f-display);
    font-weight: 700;
    font-size: 23px;
    line-height: 1.05;
    text-transform: uppercase;
    letter-spacing: .02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.plaque .meta { font-size: 12.5px; color: var(--text-dim); min-height: 1.3em; }

.icon-btn {
    width: 38px;
    height: 38px;
    flex: none;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, .08);
    color: var(--text);
    display: grid;
    place-items: center;
}
.icon-btn:hover { background: rgba(255, 255, 255, .14); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- stage ---------- */
/* the feed or the editor fill the stage; the feed bar and the tray lie over the floor at the bottom */
.stage {
    flex: 1;
    min-height: 0;
    position: relative;
}
.away { visibility: hidden; }

/* ---------- feed ---------- */
/* one door per screen; swiping snaps to the next door, nearest first */
.feed {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    overscroll-behavior: contain;
    touch-action: pan-y; /* two fingers zoom the door, not the page, see main.js */
    scrollbar-width: none;
    outline: none;
}
.feed::-webkit-scrollbar { display: none; }
.card {
    height: 100%;
    position: relative;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}
.card canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.card.end {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 14px;
    padding: 20px;
    text-align: center;
}
.card.end h2 {
    margin: 0;
    font-family: var(--f-display);
    font-size: 28px;
    line-height: 1.05;
    text-transform: uppercase;
    letter-spacing: .02em;
    text-wrap: balance;
}
.card.end p { margin: 0; max-width: 30ch; font-size: 14px; line-height: 1.5; color: var(--text-dim); }

/* on the first door: every card bounces up a little, so the top of the next door peeks in */
.feed.hint > .card { animation: peek 1.6s ease-in-out .6s 2; }
@keyframes peek {
    0%, 100% { transform: translateY(0); }
    40%, 60% { transform: translateY(-64px); }
}
.swipe-hint {
    position: absolute;
    left: 50%;
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    z-index: 10;
    transform: translateX(-50%);
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

.feed-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    display: flex;
    gap: 8px;
    padding: 10px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    background: var(--partition-dark);
}

.count {
    flex: none;
    font-size: 12.5px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    padding: 0 4px;
}

/* ---------- door scene ---------- */
.door-area {
    position: absolute;
    inset: 0;
}
.door-area canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}
.door-area canvas.sticker { cursor: move; }
.door-area .fit {
    position: absolute;
    top: 10px;
    right: 12px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
}
.door-area .fit:hover { background: rgba(0, 0, 0, .7); }

/* ---------- tray ---------- */
.tray {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    display: grid;
    gap: 10px;
    padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px));
    background: var(--partition-dark);
}
.row { display: flex; align-items: center; gap: 8px; }
/* markers or the sticker: the same height, so the tray doesn't change size when switching */
.row.tools { min-height: 36px; }
.sticker-edit {
    flex: 1;
    min-width: 0;
    height: 36px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, .08);
    color: var(--text);
    font-size: 15px;
    text-align: left;
}
.sticker-edit:hover { background: rgba(255, 255, 255, .14); }
.sticker-edit svg { flex: none; width: 17px; height: 17px; }
.sticker-edit span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modes { flex: none; display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, .07); }
.mode {
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-dim);
    display: grid;
    place-items: center;
}
.mode svg { width: 20px; height: 20px; }
.mode[aria-pressed="true"] { background: rgba(255, 255, 255, .18); color: var(--text); }
.mode:disabled { opacity: .5; cursor: default; }
.swatches { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.swatch {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25);
}
.swatch[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--partition-dark); }
.tips { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, .07); }
.tip {
    width: 34px;
    height: 30px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    display: grid;
    place-items: center;
}
.tip span { display: block; border-radius: 50%; background: var(--text); }
.tip[aria-pressed="true"] { background: rgba(255, 255, 255, .18); }

.primary {
    flex: 1;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--f-display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.primary:disabled { background: rgba(255, 255, 255, .1); color: var(--text-dim); cursor: default; }
.secondary {
    flex: 1;
    height: 44px;
    border: 1px solid rgba(0, 0, 0, .2);
    border-radius: 12px;
    background: transparent;
    color: #222;
    font-weight: 600;
}
.undo, .share { width: 44px; height: 44px; }

/* ---------- panels ---------- */
.panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 8px 20px calc(22px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
}
.panel.center { justify-content: center; align-items: center; text-align: center; }
.panel.center p { max-width: 32ch; }
.panel.center .primary { flex: none; width: 100%; max-width: 320px; }
.panel h2 {
    margin: 0;
    font-family: var(--f-display);
    font-size: 28px;
    line-height: 1.05;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.panel p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-dim); }
.panel .primary { flex: none; }
.panel p.error { color: #ffb4a8; }
.big-pin {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    color: var(--accent);
    display: grid;
    place-items: center;
}
.big-pin svg { width: 32px; height: 32px; }

/* ---------- leave sheet ---------- */
.sheet-backdrop {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(10, 16, 14, .55);
    display: flex;
    align-items: flex-end;
}
.sheet {
    width: 100%;
    display: grid;
    gap: 12px;
    padding: 20px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0;
    background: var(--paper);
    color: #222;
}
.sheet h2 {
    margin: 0;
    font-family: var(--f-display);
    font-size: 24px;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.sheet p { margin: 0; color: #555; }

/* ---------- sticker sheet ---------- */
/* lighter than the leave sheet: the door stays in sight while you pick */
#stickerSheet { background: rgba(10, 16, 14, .3); }
.sticker-sheet { max-height: 100%; overflow-y: auto; gap: 10px; }
.sticker-preview { display: block; width: 100%; height: 84px; }
/* no sticker, just the text: a checkerboard like an image editor's transparency */
.swatch.no-background, .sticker-preview.no-background {
    background: repeating-conic-gradient(#c8c8c8 0 25%, #fff 0 50%) 0 0 / 10px 10px;
}
.sticker-preview.no-background { border-radius: 10px; }
.sticker-text {
    padding: 10px 12px;
    resize: none;
    field-sizing: content; /* grows with the lines, where browsers support it */
    min-height: calc(2.6em + 20px);
    border: 1px solid rgba(0, 0, 0, .25);
    border-radius: 10px;
    background: #fff;
    color: #222;
    font: inherit;
    font-size: 17px; /* over 16px stops iOS from zooming in */
    line-height: 1.3;
}
.sticker-text:focus-visible { outline: 2px solid #222; outline-offset: 1px; }
.sticker-field { display: grid; gap: 6px; font-size: 12.5px; color: #555; }
.fonts { display: flex; flex-wrap: wrap; gap: 6px; }
.font-option {
    height: 36px;
    padding: 0 12px;
    border: 2px solid transparent;
    border-radius: 10px;
    background: rgba(0, 0, 0, .06);
    color: #222;
    font-size: 17px;
    line-height: 1;
}
.font-option[aria-checked="true"] { border-color: #222; background: #fff; }
.sticker-sheet .swatch[aria-pressed="true"] { border-color: #222; box-shadow: inset 0 0 0 2px var(--paper); }
.sticker-sheet .primary { flex: none; margin-top: 4px; }

/* ---------- toast ---------- */
.toast {
    position: absolute;
    left: 50%;
    bottom: calc(130px + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    max-width: calc(100% - 32px);
    transform: translate(-50%, 8px);
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--paper);
    color: #222;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .3);
    transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #fbe1dc; color: #7a1f14; }

@media (prefers-reduced-motion: reduce) {
    .toast { transition: none; }
    .feed.hint > .card { animation: none; }
}
