/* ============================================
   ETL - Ethmar Think Lab
   Mobile-First CSS
   ============================================ */

/* ============================================
   Root Variables & Global Styles
   ============================================ */
:root {
    --primary-blue: #124C84;
    --primary-purple: #7643A3;
    --wood-light: #a66d3a;
    --wood-dark: #5c3a21;
    --accent-light-blue: #5B9ACF;
    --accent-orange: #F28E2B;
    --bg-light: #F9FAFB;
    --text-dark: #1F2937;
    --text-light: #6B7280;
    --border-light: #E5E7EB;
    --white: #FFFFFF;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
    background-color: var(--bg-light);
    background-image: url('../images/cards.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    height: 100vh;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--primary-blue);
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

p {
    margin-bottom: 1rem;
    color: var(--text-dark);
    font-size: 1rem;
}

a {
    color: var(--primary-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-purple);
    text-decoration: underline;
}

/* ============================================
   App Container Layout
   ============================================ */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: transparent;
}

.app-header {
    background: linear-gradient(135deg, var(--wood-light) 0%, var(--wood-dark) 100%);
    color: var(--white);
    padding: 1rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

.logo-link {
    display: flex;
    align-items: center;
    transition: transform 0.2s ease;
}

.logo-link:hover {
    transform: scale(1.05);
}

.logo {
    height: 50px;
    width: auto;
    border-radius: 4px;
    background: var(--white);
    padding: 4px;
}

.app-title {
    font-size: 1.75rem;
    margin: 0;
    color: var(--white);
    font-weight: 800;
    letter-spacing: 2px;
}

/* ============================================
   Main Content Area
   ============================================ */
main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1.5rem;
    background-color: transparent;
    min-height: calc(100vh - 100px);
}

.card-container {
    width: 100%;
    max-width: 600px;
}

/* ============================================
   Card Content Rendering
   ============================================ */
.card-content {
    background: var(--white);
    border-radius: 12px;
    padding: 0;
    flex: 1;
    width: 100%;
    height: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: slideUp 0.3s ease;
    overflow-y: auto;
}

.card-content.type-video {
    background: #000;
    padding: 0 !important; /* Force remove any padding from media queries */
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.card-content h2 {
    margin: 0;
    padding: 1.5rem;
    border-bottom: 3px solid var(--primary-purple);
    color: var(--primary-blue);
    font-size: 1.5rem;
}

.card-content h2:empty {
    display: none;
    border: none;
    padding: 0;
    margin: 0;
}

.card-content > p {
    margin: 0;
    padding: 1.5rem;
    line-height: 1.7;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border-light);
}

.card-content > p:empty {
    display: none;
    margin: 0;
    padding: 0;
    border: none;
}

.card-content > p:last-of-type {
    border-bottom: none;
}

.card-content img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0;
}

.card-content video {
    width: 100%;
    height: auto;
    border-radius: 0;
    background: #000;
    max-height: none;
    display: block;
}

.card-content.type-video video {
    height: 100%;
    object-fit: contain; /* Show the entire video without cropping (adds black bars if aspect ratio differs) */
}

.card-content audio {
    width: 100%;
    margin: 1rem;
    border-radius: 4px;
    background: var(--bg-light);
    height: 45px;
    padding: 0.5rem;
    box-sizing: border-box;
}

/* ============================================
   Buttons & CTAs
   ============================================ */
.cta-button {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--primary-purple) 100%);
    color: var(--white);
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    margin: 1.5rem;
    margin-top: 0;
    box-shadow: var(--shadow-md);
    width: calc(100% - 3rem);
}

.cta-button:first-child {
    margin-top: 1.5rem;
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    text-decoration: none;
    color: var(--white);
}

.cta-button:active {
    transform: translateY(0);
}

/* ============================================
   Loading State
   ============================================ */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-light);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Mobile Frame & Centering
   ============================================ */
.card-container-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 100px);
    padding: 2rem 1rem;
}

.card-frame {
    width: 360px;
    max-width: 92vw;
    min-height: 720px;
    border-radius: 36px;
    background: linear-gradient(180deg, #0f1724 0%, #071028 100%);
    padding: 22px;
    box-shadow: 0 30px 90px rgba(18,76,132,0.18), inset 0 0 0 2px #2a3548;
    display: flex;
    justify-content: center;
    position: relative;
}

.card-frame::before {
    content: '';
    height: 26px;
    width: 120px;
    background: #000;
    position: absolute;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    z-index: 10;
}

.card-screen {
    width: 100%;
    flex: 1;
    background: var(--white);
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Loading phone mockup */
.mobile-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 80px);
    perspective: 1200px; /* For 3D effect */
}

.phone-body {
    width: 360px;
    max-width: 92vw;
    height: 720px;
    position: relative;
    transform-style: preserve-3d;
}

.flip-animation {
    animation: phoneFlip 1.5s cubic-bezier(0.45, 0.05, 0.22, 1.3) forwards;
    animation-delay: 0.5s;
    /* Starts showing the back */
}

.phone-face {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border-radius: 36px;
    background: linear-gradient(180deg, #0f1724 0%, #071028 100%);
    box-shadow: 0 30px 90px rgba(18,76,132,0.18), inset 0 0 0 2px #2a3548;
    backface-visibility: hidden;
    padding: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Back of the phone */
.phone-back {
    transform: rotateY(0deg);
}

.camera-bump {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 60px;
    height: 120px;
    background: #000;
    border-radius: 20px;
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.1), 0 2px 10px rgba(0,0,0,0.5);
    border: 1px solid #1a2235;
}

.camera-bump::before, .camera-bump::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: #111;
    border-radius: 50%;
    left: 50%;
    transform: translateX(-50%);
    border: 2px solid #333;
    box-shadow: inset 0 0 10px #000, 0 0 2px rgba(255,255,255,0.2);
}

.camera-bump::before { top: 15px; }
.camera-bump::after { bottom: 15px; }

.back-logo {
    width: 120px;
    height: auto;
    border-radius: 16px;
    opacity: 0.8;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    /* Logo stands straight up on the back of the phone */
}

/* Front of the phone */
.phone-front {
    transform: rotateY(180deg);
    flex-direction: column;
}

.phone-screen {
    width: 100%;
    height: 100%;
    border-radius: 18px;
    background: #000;
    overflow: hidden;
    position: relative;
}

.screen-notch {
    height: 26px;
    width: 120px;
    background: #000;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    z-index: 10;
}

.phone-screen .screen-content {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    color: var(--white);
    background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 14px 14px;
}

@keyframes phoneFlip {
    0% { transform: rotateY(0deg) scale(0.9); }
    50% { transform: rotateY(90deg) scale(0.8); }
    100% { transform: rotateY(180deg) scale(1); }
}


/* ============================================
   Error Messages
   ============================================ */
.error-message {
    background: #FEE2E2;
    color: #991B1B;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #DC2626;
    margin: 1.5rem 0;
    animation: slideUp 0.3s ease;
}

.error-message h3 {
    color: #991B1B;
    margin-top: 0;
}

.error-message p {
    color: #991B1B;
    margin-bottom: 0;
}

/* ============================================
   Card Not Found / Inactive States
   ============================================ */
.empty-state {
    text-align: center;
    padding: 2rem 1.5rem;
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.empty-state h2 {
    color: var(--primary-blue);
    margin-bottom: 1rem;
}

.empty-state p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.home-button {
    display: inline-block;
    background: var(--primary-blue);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.home-button:hover {
    background: var(--primary-purple);
    transform: translateY(-2px);
    text-decoration: none;
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   Animations
   ============================================ */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Media Queries
   ============================================ */

/* Small phones (< 375px) */
@media (max-width: 374px) {
    :root {
        font-size: 14px;
    }

    .header-content {
        gap: 0.75rem;
    }

    .logo {
        height: 40px;
    }

    .app-title {
        font-size: 1.5rem;
    }

    .card-content {
        padding: 1rem;
    }

    main {
        padding: 1rem;
    }

    .cta-button {
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
    }
}

/* Medium phones (375px - 767px) */
@media (min-width: 375px) and (max-width: 767px) {
    /* Mobile defaults already applied */
}

/* Tablets (768px - 1024px) */
@media (min-width: 768px) {
    :root {
        font-size: 17px;
    }

    h1 {
        font-size: 2.25rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    .card-container {
        max-width: 700px;
    }

    .card-content {
        padding: 2rem;
    }

    main {
        padding: 2rem;
    }

    .header-content {
        padding: 0 2rem;
    }
}

/* Large screens (1025px+) */
@media (min-width: 1025px) {
    :root {
        font-size: 18px;
    }

    h1 {
        font-size: 2.5rem;
    }

    .card-container {
        max-width: 800px;
    }

    .card-content {
        padding: 2.5rem;
    }

    main {
        padding: 2.5rem;
    }
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-light: #111827;
        --text-dark: #F3F4F6;
        --text-light: #D1D5DB;
        --border-light: #374151;
        --white: #1F2937;
    }

    .card-content {
        background: #1F2937;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }

    .card-content > p {
        color: #E5E7EB;
    }

    .cta-button {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
}

/* ============================================
   Focus & Keyboard Navigation
   ============================================ */
a:focus,
button:focus,
.cta-button:focus {
    outline: 2px solid var(--accent-light-blue);
    outline-offset: 2px;
}

/* ============================================
   Modals & Overlays
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
    position: relative;
}

.modal-content.modal-full {
    max-width: 95vw;
    max-height: 95vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.modal-content.modal-small {
    max-width: 350px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
    margin: 0;
    flex: 1;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    max-height: calc(95vh - 100px);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

/* ============================================
   Redirect Modal Styles
   ============================================ */
.redirect-loader {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-light);
    border-top-color: var(--accent-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

#redirect-modal h2 {
    text-align: center;
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
}

#redirect-modal p {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.redirect-countdown {
    font-size: 0.9rem;
    color: var(--accent-orange);
    font-weight: 600;
}

/* ============================================
   PDF Viewer
   ============================================ */
.pdf-viewer {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    min-height: 500px;
}

/* ============================================
   Confirmation Modal
   ============================================ */
.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-cancel,
.btn-confirm {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel {
    background: var(--border-light);
    color: var(--text-dark);
}

.btn-cancel:hover {
    background: #d1d5db;
}

.btn-confirm {
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--primary-purple) 100%);
    color: var(--white);
}

.btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ============================================
   Fade In Animation
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Print styles */
@media print {
    .app-header {
        background: var(--primary-blue);
        color: var(--white);
    }

    main {
        padding: 0;
    }

    .modal {
        display: none !important;
    }
}
