/* Same palette as the Android app (res/values/colors.xml) */
:root {
    --background: #05060a;
    --surface: #14161f;
    --glass: rgba(20, 22, 31, 0.77);
    --hairline: rgba(255, 255, 255, 0.08);
    --text: #ffffff;
    --muted: #9aa0b4;
    --accent: #8ab4ff;
    --radius: 24px;
    --gutter: max(20px, env(safe-area-inset-left, 0px));
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* Leave room for the bottom tabs */
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

.screen {
    max-width: 680px;
    margin: 0 auto;
}

h1, h2 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    text-wrap: balance;
    font-size: 1.6rem;
}

.label {
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
}

button, .icon-button {
    font: inherit;
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

button:disabled {
    color: var(--muted);
    opacity: 0.4;
    cursor: default;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.button {
    min-height: 48px;
    padding: 0 20px;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 999px;
    font-size: 0.85rem;
}

/* ---------- Hero picture ---------- */

.hero {
    position: relative;
    min-height: 360px;
    background: var(--surface);
    overflow: hidden;
    touch-action: pan-y; /* Vertical scroll stays native; horizontal swipes change the day */
}

.hero img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 300ms;
}

/* Darkens the top and bottom so the buttons and title stay readable */
.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(0, 0, 0, 0.4), transparent 30%, transparent 55%, rgba(5, 6, 10, 0.93));
    pointer-events: none;
}

.hero-actions {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(20px + env(safe-area-inset-top, 0px)) var(--gutter) 0;
}

.hero-actions .label {
    flex: 1;
    color: var(--text);
}

.icon-button {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    background: var(--glass);
    border: 1px solid var(--hairline);
    border-radius: 50%;
    font-size: 1.3rem;
    text-decoration: none;
}

.icon-button[aria-pressed="true"] {
    color: var(--accent);
}

.title-card {
    position: absolute;
    z-index: 1;
    left: var(--gutter);
    right: var(--gutter);
    bottom: 20px;
    padding: 20px;
    background: var(--glass);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
}

.title-card .label {
    margin: 8px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Days without a photo: no picture, buttons or story, and the message shows in full */
.no-photo #imagePicture,
.no-photo .icon-button,
.no-photo .story {
    display: none;
}

.no-photo .title-card .label {
    display: block;
    white-space: pre-line;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.9rem;
}

/* ---------- Day navigation ---------- */

.day-nav {
    display: flex;
    gap: 8px;
    padding: 20px var(--gutter);
}

.day-controls {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.day-controls > button {
    min-height: 48px;
    padding: 0 16px;
    background: none;
    border: 0;
    font-size: 0.85rem;
}

.date-chip {
    position: relative;
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.date-chip input {
    position: absolute;
    inset: 0;
    width: 100%;
    opacity: 0;
    cursor: pointer;
}

.today {
    color: var(--accent);
}

.story {
    margin: 0 var(--gutter) 20px;
    padding: 20px;
}

.story p {
    margin: 12px 0 0;
    line-height: 1.75;
}

/* ---------- Loading and error ---------- */

.loading {
    display: grid;
    gap: 20px;
}

.skeleton {
    display: grid;
    place-items: center;
}

.skeleton-bar {
    height: 48px;
    margin: 0 var(--gutter);
}

.skeleton-bar.tall {
    height: 64px;
}

.loading > * {
    animation: pulse 800ms ease-in-out infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.45; }
}

.error {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: calc(80px + env(safe-area-inset-top, 0px)) var(--gutter) 0;
    text-align: center;
}

.error p {
    color: var(--muted);
}

/* ---------- Favorites ---------- */

.favorites-screen {
    padding: calc(20px + env(safe-area-inset-top, 0px)) var(--gutter) 20px;
}

.favorites-screen h2 {
    margin-top: 8px;
}

.hint {
    color: var(--muted);
    font-size: 0.8rem;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding-block: 64px;
}

.grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.grid li {
    position: relative;
    height: 240px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface);
}

.grid .open {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 12px;
    background: none;
    border: 0;
    text-align: left;
}

.grid img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grid .open::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(transparent 40%, rgba(5, 6, 10, 0.9));
}

.grid strong, .grid .label {
    position: relative;
}

.grid strong {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.grid .label {
    margin-top: 8px;
}

.grid .remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
}

/* Shown on the card after tapping ✕ */
.confirm {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    align-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--glass);
    text-align: center;
}

/* ---------- Bottom tabs and toast ---------- */

.tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    background: var(--background);
    border-top: 1px solid var(--hairline);
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.tab {
    flex: 1;
    height: 64px;
    background: none;
    border: 0;
    color: var(--muted);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.tab.active {
    color: var(--text);
    /* Short accent line under the active tab */
    background: linear-gradient(var(--accent), var(--accent)) center 44px / 24px 2px no-repeat;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    z-index: 3;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--background);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
    .loading > * {
        animation: none;
    }
    .hero img {
        transition: none;
    }
}
