/**
 * Highline Adventures Login - Glassmorphic Styles
 * Inspired by the ops application design
 */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Contour-Kit Color Palette - RGB triplets for alpha manipulation */
    --rgb-faded-copper: 159, 122, 83;    /* #9F7A53 - Primary accent */
    --rgb-khaki-beige: 183, 173, 149;    /* #B7AD95 - Light accent */
    --rgb-white: 255, 255, 255;

    /* Glass Physics */
    --glass-opacity: 0.12;
    --glass-blur: 16px;
    --glass-border-opacity: 0.25;

    /* Card styling */
    --card-border-radius: 20px;
}

html {
    overflow: hidden;
    background-color: rgb(20, 20, 20);
}

body {
    font-family: 'Rubik', 'Roboto', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: rgb(20, 20, 20);
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
}

/* Keyframe animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes bounce {
    from, 6.66%, 17.66%, 33.33% {
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        transform: translate3d(0, 0, 0);
    }
    13.33%, 14.33% {
        animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
        transform: translate3d(0, -30px, 0) scaleY(1.1);
    }
    23.33% {
        animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
        transform: translate3d(0, -15px, 0) scaleY(1.05);
    }
    26.66% {
        transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        transform: translate3d(0, 0, 0) scaleY(0.95);
    }
    30% {
        transform: translate3d(0, -4px, 0) scaleY(1.02);
    }
}

@keyframes subtleZoom {
    0% { transform: scale(1.1); }
    100% { transform: scale(1.15); }
}

/* Background utility */
.background-image {
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

/* Main app container */
#app-login {
    background-color: #1e1e1e;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Background */
#app-background {
    height: 100vh;
    left: 0;
    overflow: hidden;
    position: fixed;
    top: 0;
    right: 0;
    width: 100vw;
    z-index: 1;
}

#app-background-image {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transition: filter 250ms, transform 250ms;
    background-image: url('assets/bg-pattern.jpg');
    transform: scale(1.1);
}

@media (prefers-reduced-motion: no-preference) {
    #app-background-image {
        animation: subtleZoom 30s ease-in-out infinite alternate;
    }
}

/* Logged-out state */
#app-login.logged-out #app-info {
    margin-left: 40px;
    opacity: 1;
    transform: translateX(0%);
}

#app-login.logged-out #app-background {
    cursor: pointer;
}

#app-login.logged-out #sign-in-button-wrapper {
    opacity: 1;
    pointer-events: all;
    transform: translate(-50%, -40px);
    visibility: visible;
}

/* Logging-in, verifying, error states - blur background */
#app-login.logging-in #app-background-image,
#app-login.verifying-log-in #app-background-image,
#app-login.log-in-error #app-background-image {
    filter: blur(8px);
    transform: scale(1.2);
}

/* Logging-in and error - show PIN */
#app-login.logging-in #app-pin-wrapper,
#app-login.log-in-error #app-pin-wrapper {
    opacity: 1;
    pointer-events: all;
    transform: translate(-50%, -50%) scale(1);
    visibility: visible;
}

/* Verifying - show loading spinner */
#app-login.verifying-log-in #app-loading-icon {
    opacity: 1;
    transform: translate(-50%, -50%);
    visibility: visible;
}

/* App info (time + weather) */
#app-info {
    bottom: 0;
    left: 0;
    margin: 40px;
    margin-left: 0;
    opacity: 0;
    position: absolute;
    transform: translateX(-100%);
    transition: margin 250ms, opacity 250ms, transform 250ms;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.time-weather-row {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 16px;
}

.time-text {
    font-size: 6rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1;
}

.temperature-text {
    font-size: 1.5rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.3);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.date-text {
    font-size: 2rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.3);
    font-variant-numeric: tabular-nums;
    letter-spacing: 8px;
    line-height: 1;
}

/* Sign-in icon */
#sign-in-button {
    cursor: pointer;
    font-size: 3rem;
    color: whitesmoke;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: all 0.3s ease;
    user-select: none;
}

#sign-in-button:hover {
    filter: drop-shadow(0 6px 12px rgba(255, 255, 255, 0.5));
    transform: scale(1.1);
}

/* Sign-in button wrapper */
#sign-in-button-wrapper {
    bottom: 0;
    left: 50%;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    transform: translate(-50%, 40px);
    transition: opacity 250ms, transform 250ms, visibility 250ms;
    visibility: hidden;
    z-index: 2;
}

/* Bounce animation for sign-in button */
#sign-in-button-wrapper #sign-in-button:not(:hover) {
    animation: bounce 3s infinite;
    animation-delay: 3s;
}

/* PIN wrapper */
#app-pin-wrapper {
    left: 50%;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -30%) scale(0.8);
    transition: opacity 250ms, transform 250ms, visibility 250ms;
    visibility: hidden;
    z-index: 2;
}

/* PIN Auth Wrapper - Modern Ops Design */
.pin-auth-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.pin-hidden-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
    border: none;
    outline: none;
}

.pin-display {
    display: flex;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.pin-digit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 80px;
    font-size: 3em;
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: background-color 250ms;
    overflow: hidden;
}

.pin-digit.focused::before {
    content: '';
    position: absolute;
    bottom: 0px;
    left: 15%;
    width: 70%;
    height: 3px;
    background-color: whitesmoke;
    border-radius: 10px;
    opacity: 1;
    transform: translateY(-10px);
    animation: blink 2s ease-in-out infinite;
    z-index: 2;
}

@keyframes blink {
    from, 25%, to {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

.pin-digit.error {
    background-color: rgba(239, 83, 80, 0.05);
}

.pin-digit-value {
    color: whitesmoke;
    font-weight: 400;
    transition: opacity 250ms, transform 250ms;
    z-index: 1;
}

.pin-digit.hidden .pin-digit-value {
    opacity: 0;
    transform: scale(0.25);
}

.pin-digit-dot {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: whitesmoke;
    border-radius: 20px;
    opacity: 0;
    transform: scale(0.25);
    transition: opacity 250ms, transform 250ms;
    z-index: 2;
}

.pin-digit.hidden .pin-digit-dot {
    opacity: 1;
    transform: scale(1);
}

.pin-label {
    color: whitesmoke;
    font-size: 0.9em;
    margin: 10px;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.pin-instruction {
    color: whitesmoke;
}

.pin-error {
    color: #ef5350;
    font-weight: 400;
    margin-left: 4px;
}

.pin-cancel {
    color: whitesmoke;
    cursor: pointer;
    margin-left: 4px;
}

.pin-cancel:hover {
    text-decoration: underline;
}

/* Loading icon */
#app-loading-icon {
    left: 50%;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translate(-50%, 0%);
    transition: opacity 250ms, transform 250ms, visibility 250ms;
    visibility: hidden;
    z-index: 2;
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: rgba(var(--rgb-faded-copper), 1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-text {
    color: white;
    font-size: 1.2rem;
    font-weight: 500;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Responsive adjustments */
@media (max-width: 1300px) {
    #app-login.logged-out #sign-in-button-wrapper {
        transform: translate(-40px, 0px);
    }

    #sign-in-button-wrapper {
        bottom: 40px;
        left: auto;
        right: 0;
        transform: translate(40px, 0px);
    }
}

@media (max-width: 960px) {
    .time-text {
        font-size: 5rem;
    }

    .temperature-text,
    .date-text {
        font-size: 1.25rem;
    }

    .date-text {
        letter-spacing: 6px;
    }
}

@media (max-width: 600px) {
    .pin-digit {
        width: 60px;
        height: 80px;
        font-size: 2.5rem;
    }

    .pin-display {
        gap: 8px;
    }

    /* Center password button on mobile */
    #sign-in-button-wrapper {
        bottom: auto;
        left: 50%;
        right: auto;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    #app-login.logged-out #sign-in-button-wrapper {
        transform: translate(-50%, -50%);
    }

    #app-info {
        margin: 20px;
    }

    #app-login.logged-out #app-info {
        margin-left: 20px;
    }

    .time-text {
        font-size: 4rem;
    }

    .temperature-text,
    .date-text {
        font-size: 1.125rem;
    }

    .date-text {
        letter-spacing: 6px;
    }

    #sign-in-button {
        font-size: 3rem;
    }
}

@media (max-width: 400px) {
    .pin-digit {
        width: 50px;
        height: 70px;
        font-size: 2rem;
    }

    .pin-display {
        gap: 6px;
    }

    .time-text {
        font-size: 3rem;
    }

    .temperature-text,
    .date-text {
        font-size: 1rem;
    }

    .date-text {
        letter-spacing: 6px;
    }
}

/* iPhone SE and similar (375px and below) */
@media (max-width: 375px) {
    .time-text {
        font-size: 2.5rem; /* Further reduced for very small screens */
    }

    .temperature-text {
        font-size: 0.95rem;
    }

    .date-text {
        font-size: 0.95rem;
        letter-spacing: 4px;
    }
}

/* ============================================================================
   MENU ICON & SIDEBAR NAVIGATION
   ============================================================================ */

/* Menu Icon Button (Top Right) */
.menu-icon-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-icon-btn:hover {
    transform: scale(1.1);
}

.menu-icon-btn .material-symbols-outlined {
    font-size: 32px;
    color: white;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
    transition: all 0.3s ease;
}

.menu-icon-btn:hover .material-symbols-outlined {
    filter: drop-shadow(0 4px 12px rgba(255, 255, 255, 0.6));
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 998;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Container */
.sidebar {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100%;
    -webkit-backdrop-filter: blur(20px);
    z-index: 999;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.sidebar.open {
    right: 0;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 20px;
}

.sidebar-header h2 {
    color: rgba(var(--rgb-faded-copper), 1);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.sidebar-header .close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.sidebar-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-header .close-btn .material-symbols-outlined {
    font-size: 28px;
    color: white;
}

/* Sidebar Content */
.sidebar-content {
    padding: 20px;
}

/* Sidebar Links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    color: white;
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 1rem;
    margin-bottom: 6px;
    background: transparent;
    border: none;
}

.sidebar-link:hover {
    opacity: 0.8;
}

.sidebar-link .material-symbols-outlined {
    font-size: 28px;
    color: rgba(var(--rgb-faded-copper), 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.sidebar-link span:last-child {
    flex: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Mobile Sidebar Width Adjustment */
@media (max-width: 480px) {
    .sidebar {
        width: 300px;
        right: -300px;
    }

    .menu-icon-btn {
        top: 16px;
        right: 16px;
    }

    .menu-icon-btn .material-symbols-outlined {
        font-size: 28px;
    }
}
