/* ==========================================================
   LunarNames
   Version 0.1
   ========================================================== */

:root {
    --blue: #007aff;
    --blue-dark: #0062cc;
    --green: #34c759;
    --red: #ff3b30;

    --background: #f2f2f7;
    --surface: #ffffff;
    --surface-secondary: #e5e5ea;

    --text: #1c1c1e;
    --secondary-text: #6e6e73;
    --tertiary-text: #8e8e93;

    --border: #d1d1d6;

    --radius-small: 14px;
    --radius-medium: 20px;
    --radius-large: 28px;

    --shadow:
        0 8px 30px rgba(0, 0, 0, 0.08);

    --screen-width: 520px;
}

/* ==========================================================
   Reset
   ========================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
    background: var(--background);
}

body {
    min-height: 100vh;
    overflow-x: hidden;

    background: var(--background);
    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "SF Pro Display",
        "SF Pro Text",
        "Helvetica Neue",
        Arial,
        sans-serif;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

img,
video {
    max-width: 100%;
}

/* ==========================================================
   Screens
   ========================================================== */

#app {
    min-height: 100vh;
}

.screen {
    display: none;

    width: 100%;
    max-width: var(--screen-width);
    min-height: 100vh;

    margin: 0 auto;

    padding:
        max(24px, env(safe-area-inset-top))
        22px
        max(30px, env(safe-area-inset-bottom));
}

.screen.active {
    display: block;
    animation: screen-enter 280ms ease-out;
}

@keyframes screen-enter {
    from {
        opacity: 0;
        transform: translateX(24px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==========================================================
   Home
   ========================================================== */

#home-screen {
    align-content: center;
}

#home-screen.active {
    display: grid;
}

.home-content {
    width: 100%;
    padding: 24px 0;
    text-align: center;
}

.brand-mark {
    color: var(--blue);
    font-size: 70px;
    line-height: 1;
    margin-bottom: 16px;
}

h1 {
    font-size: clamp(42px, 11vw, 56px);
    line-height: 1;
    letter-spacing: -2px;
    font-weight: 750;
}

.tagline {
    margin-top: 10px;
    color: var(--blue);
    font-size: 20px;
    font-weight: 600;
}

.home-description {
    max-width: 360px;
    margin: 28px auto 0;

    color: var(--secondary-text);
    font-size: 17px;
    line-height: 1.45;
}

.home-actions {
    margin-top: 38px;
}

.primary-button,
.secondary-button {
    display: block;
    width: 100%;
    min-height: 54px;

    margin-top: 14px;
    padding: 14px 20px;

    border: none;
    border-radius: 16px;

    cursor: pointer;

    font-size: 18px;
    font-weight: 650;

    transition:
        transform 150ms ease,
        background 150ms ease,
        opacity 150ms ease;
}

.primary-button {
    background: var(--blue);
    color: white;
}

.primary-button:active {
    background: var(--blue-dark);
    transform: scale(0.98);
}

.secondary-button {
    background: var(--surface);
    color: var(--blue);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.secondary-button:active {
    background: #eeeeF3;
    transform: scale(0.98);
}

.progress-card {
    margin-top: 34px;
    padding: 18px;

    background: var(--surface);
    border-radius: var(--radius-medium);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);

    text-align: left;
}

.progress-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;

    color: var(--secondary-text);
    font-size: 14px;
    font-weight: 600;
}

.progress-track {
    height: 8px;
    margin-top: 12px;

    overflow: hidden;

    background: var(--surface-secondary);
    border-radius: 999px;
}

.progress-bar {
    width: 0%;
    height: 100%;

    background: var(--blue);
    border-radius: inherit;

    transition: width 300ms ease;
}

/* ==========================================================
   Headers
   ========================================================== */

.screen-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;

    min-height: 44px;
    margin-bottom: 22px;
}

.screen-header h2 {
    font-size: 20px;
    line-height: 1;
    text-align: center;
}

.navigation-button {
    appearance: none;

    min-height: 44px;
    padding: 8px 0;

    background: transparent;
    border: none;

    color: var(--blue);

    cursor: pointer;

    font-size: 17px;
}

.navigation-button:active {
    opacity: 0.55;
}

.back-button {
    justify-self: start;
    text-align: left;
}

.directory-button {
    justify-self: end;
    text-align: right;
}

.header-spacer {
    display: block;
}

/* ==========================================================
   Person Card
   ========================================================== */

.person-card {
    overflow: hidden;

    background: var(--surface);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow);

    transform: translateX(0);
    opacity: 1;

    transition:
        transform 220ms ease,
        opacity 220ms ease;

    touch-action: pan-y;
}

.person-card.is-leaving-left {
    transform: translateX(-115%);
    opacity: 0;
}

.person-card.is-leaving-right {
    transform: translateX(115%);
    opacity: 0;
}

.person-card.is-entering-left {
    animation: card-enter-left 240ms ease;
}

.person-card.is-entering-right {
    animation: card-enter-right 240ms ease;
}

@keyframes card-enter-left {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes card-enter-right {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==========================================================
   Photo and Video
   ========================================================== */

.media-button {
    position: relative;

    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;

    overflow: hidden;

    background: var(--surface-secondary);
    border: none;

    cursor: pointer;
}

.person-photo,
.person-video {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    display: block;
    object-fit: cover;

    transition: opacity 220ms ease;
}

.person-photo {
    opacity: 1;
}

.person-video {
    opacity: 0;
    pointer-events: none;
}

.media-button.is-playing .person-photo {
    opacity: 0;
}

.media-button.is-playing .person-video {
    opacity: 1;
}

.video-prompt {
    position: absolute;
    left: 50%;
    bottom: 18px;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    max-width: calc(100% - 32px);
    padding: 10px 14px;

    transform: translateX(-50%);

    background: rgba(0, 0, 0, 0.6);
    color: white;

    border-radius: 999px;

    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    transition:
        opacity 180ms ease,
        transform 180ms ease;
}

.media-button.is-playing .video-prompt {
    opacity: 0;
    transform: translate(-50%, 8px);
}

.media-button.no-video {
    cursor: default;
}

.media-button.no-video .video-prompt {
    display: none;
}

.video-play-icon {
    font-size: 11px;
}

/* ==========================================================
   Person Information
   ========================================================== */

.person-details {
    padding: 26px 22px 28px;
    text-align: center;
}

.person-name {
    font-size: clamp(28px, 8vw, 34px);
    line-height: 1.12;
    letter-spacing: -0.7px;
}

.person-phonetic {
    margin-top: 8px;

    color: var(--secondary-text);

    font-size: 18px;
    line-height: 1.3;
}

.audio-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;

    min-height: 48px;

    margin-top: 24px;
    padding: 12px 18px;

    background: rgba(0, 122, 255, 0.12);
    color: var(--blue);

    border: none;
    border-radius: 15px;

    cursor: pointer;

    font-size: 17px;
    font-weight: 650;

    transition:
        transform 150ms ease,
        background 150ms ease;
}

.audio-button:active {
    background: rgba(0, 122, 255, 0.2);
    transform: scale(0.97);
}

.audio-button.is-playing .audio-symbol {
    animation: audio-pulse 700ms ease-in-out infinite alternate;
}

.audio-button[hidden] {
    display: none;
}

@keyframes audio-pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.25);
    }
}

/* ==========================================================
   Browse Controls
   ========================================================== */

.browse-controls {
    display: grid;
    grid-template-columns: 54px 1fr 54px;
    align-items: center;
    gap: 16px;

    margin-top: 22px;
}

.circle-button {
    width: 54px;
    height: 54px;

    background: var(--surface);
    color: var(--blue);

    border: none;
    border-radius: 50%;

    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.08);

    cursor: pointer;

    font-size: 32px;
    line-height: 1;

    transition:
        transform 150ms ease,
        opacity 150ms ease;
}

.circle-button:active {
    transform: scale(0.93);
}

.circle-button:disabled {
    opacity: 0.35;
    cursor: default;
}

.person-position {
    color: var(--secondary-text);

    text-align: center;
    font-size: 15px;
    font-weight: 500;
}

.swipe-hint {
    margin-top: 13px;

    color: var(--tertiary-text);

    text-align: center;
    font-size: 13px;
}

/* ==========================================================
   Directory
   ========================================================== */

.search-container {
    position: sticky;
    top: 0;
    z-index: 5;

    padding-bottom: 14px;

    background: var(--background);
}

.search-input {
    width: 100%;
    height: 46px;

    padding: 0 16px;

    background: var(--surface-secondary);
    color: var(--text);

    border: 1px solid transparent;
    border-radius: 13px;

    outline: none;

    font-size: 17px;

    transition:
        background 150ms ease,
        border-color 150ms ease;
}

.search-input:focus {
    background: var(--surface);
    border-color: rgba(0, 122, 255, 0.4);
}

.directory-list {
    overflow: hidden;

    background: var(--surface);
    border-radius: var(--radius-medium);
}

.directory-person {
    display: grid;
    grid-template-columns: 58px 1fr auto;
    align-items: center;
    gap: 14px;

    width: 100%;
    min-height: 78px;

    padding: 10px 14px;

    background: var(--surface);
    color: var(--text);

    border: none;
    border-bottom: 1px solid var(--border);

    cursor: pointer;
    text-align: left;
}

.directory-person:last-child {
    border-bottom: none;
}

.directory-person:active {
    background: #eeeeF3;
}

.directory-photo {
    width: 54px;
    height: 54px;

    display: block;
    object-fit: cover;

    border-radius: 50%;

    background: var(--surface-secondary);
}

.directory-name {
    font-size: 17px;
    font-weight: 600;
}

.directory-phonetic {
    margin-top: 3px;

    color: var(--secondary-text);

    font-size: 14px;
}

.directory-chevron {
    color: var(--tertiary-text);
    font-size: 26px;
}

.directory-empty {
    margin-top: 40px;

    color: var(--secondary-text);

    text-align: center;
    font-size: 17px;
}

/* ==========================================================
   Placeholder Screens
   ========================================================== */

.placeholder-card {
    margin-top: 28px;
    padding: 28px;

    background: var(--surface);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow);
}

.placeholder-card h3 {
    font-size: 24px;
}

.placeholder-card p {
    margin-top: 12px;

    color: var(--secondary-text);

    font-size: 17px;
    line-height: 1.5;
}

/* ==========================================================
   Accessibility
   ========================================================== */

.visually-hidden {
    position: absolute;

    width: 1px;
    height: 1px;

    padding: 0;
    margin: -1px;

    overflow: hidden;
    clip: rect(0, 0, 0, 0);

    white-space: nowrap;
    border: 0;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(0, 122, 255, 0.35);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}