/* 
   CUTI Labs - Premium Apple-like Aesthetic 
   Brighter, Cleaner, Professional
*/

:root {
    --bg-primary: #F5F5F7;
    --bg-secondary: #FFFFFF;
    --text-primary: #1D1D1F;
    --text-secondary: #64748B;
    --accent: #4F46E5;
    --border-subtle: rgba(0, 0, 0, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --radius-lg: 32px;
    --radius-md: 18px;
    --shimmer: linear-gradient(90deg, #F5F5F7 25%, #EBEBEF 37%, #F5F5F7 63%);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.015em;
    font-feature-settings: "ss01", "ss02", "cv01", "cv02";
}

/* Dark text on headers for light backgrounds — scoped to avoid overriding dark tiles */
h1,
h2,
h3,
h4,
.font-serif,
.font-serif-premium {
    color: var(--text-primary);
    font-family: "SF Pro Display", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial", serif;
}

/* White headings inside dark-background tiles — override above */
.showcase-tile h1,
.showcase-tile h2,
.showcase-tile h3,
.showcase-tile h4,
[style*="background: linear-gradient"] h1,
[style*="background: linear-gradient"] h2,
[style*="background: linear-gradient"] h3,
.clinical-tool-card.bg-\[\\#1D1D1F\] h1,
.clinical-tool-card.bg-\[\\#1D1D1F\] h2,
.clinical-tool-card.bg-\[\\#1D1D1F\] h3 {
    color: #ffffff;
}


h1 {
    font-weight: 800;
}

h2 {
    font-weight: 700;
}

/* Shimmer / Skeleton Placeholder */
.shimmer {
    background: var(--shimmer);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: 12px;
}

@keyframes shimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Custom Scrollbar */
.custom-scroll::-webkit-scrollbar {
    width: 6px;
}

.custom-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Glass Effects */
.glass-nav {
    background: var(--glass-bg);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.glass-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.04);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-panel:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 32px 64px -16px rgba(0, 0, 0, 0.1);
    border-color: rgba(79, 70, 229, 0.15);
}

/* Background Grids & Accents */
.grid-bg {
    background-size: 30px 30px;
    background-image:
        linear-gradient(to right, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
    mask-image: radial-gradient(circle at center, black 10%, transparent 90%);
}

.bg-glow-vignette {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 50%, white 0%, rgba(245, 245, 247, 0.8) 100%);
}

/* Premium Reveal System */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    visibility: hidden;
}

.fade-in {
    opacity: 0;
    animation: fadeIn 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Functional Component Tweaks */
.text-gradient-premium {
    background: linear-gradient(135deg, #1d1d1f 0%, #434343 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.text-gradient-accent {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* Forms - Make everything light & bright */
input,
textarea,
select {
    background-color: #F5F5F7 !important;
    color: #1D1D1F !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    font-weight: 500;
}

input:focus,
textarea:focus,
select:focus {
    background-color: white !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.05) !important;
}

::placeholder {
    color: #A1A1AA !important;
    opacity: 0.6;
}

/* Utilities */
.rounded-3xl {
    border-radius: 24px;
}

.rounded-4xl {
    border-radius: 32px;
}

.rounded-5xl {
    border-radius: 40px;
}

/* Overrides for specific tools */
.sensation-marker {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.breath-circle {
    transition: all 4.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   APP MODE — Immersive Native-Feel System
   ============================================= */

/* Body lock in app mode */
body.is-app-mode {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
}

/* App Bar — frosted minimal top bar */
.app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    background: rgba(245, 245, 247, 0.82);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transform: translateY(-100%);
    animation: appBarSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards;
}

@keyframes appBarSlideIn {
    to {
        transform: translateY(0);
    }
}

.app-bar-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s;
    flex-shrink: 0;
}

.app-bar-back:hover {
    background: rgba(0, 0, 0, 0.05);
}

.app-bar-back svg {
    width: 22px;
    height: 22px;
}

.app-bar-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    white-space: nowrap;
    pointer-events: none;
}

.app-bar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.app-bar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.app-bar-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.app-bar-btn:active {
    transform: scale(0.92);
}

.app-bar-btn svg {
    width: 18px;
    height: 18px;
}

/* App content viewport */
.app-mode-main {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    opacity: 0;
    animation: appContentFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards;
}

@keyframes appContentFadeIn {
    to {
        opacity: 1;
    }
}

/* ---- Navigation Drawer ---- */
.app-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 198;
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: background 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.app-drawer-backdrop.is-open {
    background: rgba(0, 0, 0, 0.35);
    pointer-events: all;
}

.app-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 199;
    background: #FFFFFF;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    will-change: transform;
}

.app-drawer.is-open {
    transform: translateX(0);
}

.app-drawer-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-drawer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 17px;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.app-drawer-logo svg {
    width: 18px;
    height: 18px;
}

.app-drawer-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.app-drawer-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.app-drawer-close svg {
    width: 18px;
    height: 18px;
}

.app-drawer-section-label {
    padding: 20px 20px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    opacity: 0.6;
}

.app-drawer-links {
    flex: 1;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-drawer-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.app-drawer-link:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

.app-drawer-link:active {
    transform: scale(0.97);
}

.app-drawer-link.is-active {
    background: var(--text-primary);
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.app-drawer-link svg {
    width: 18px;
    height: 18px;
    opacity: 0.6;
    flex-shrink: 0;
}

.app-drawer-link.is-active svg {
    opacity: 1;
}

.app-drawer-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.app-drawer-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 0;
    transition: color 0.2s;
}

.app-drawer-footer a:hover {
    color: var(--text-primary);
}

.app-drawer-footer a svg {
    width: 14px;
    height: 14px;
}

/* ---- Documentation Bottom Sheet ---- */
.app-docs-backdrop {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: background 0.35s;
}

.app-docs-backdrop.is-open {
    background: rgba(0, 0, 0, 0.4);
    pointer-events: all;
}

.app-docs-modal {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 301;
    max-height: 82dvh;
    background: #FFFFFF;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.1);
}

.app-docs-modal.is-open {
    transform: translateY(0);
}

.app-docs-handle {
    width: 36px;
    height: 4px;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
}

.app-docs-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 24px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.app-docs-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #F0F0F5, #E8E8ED);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-docs-icon svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.app-docs-title-group h3 {
    font-size: 18px !important;
    font-weight: 700;
    margin: 0 0 2px;
    letter-spacing: -0.02em;
}

.app-docs-title-group span {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.app-docs-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 24px;
    overscroll-behavior: contain;
}

.app-docs-content section {
    margin-bottom: 24px;
}

.app-docs-content section:last-child {
    margin-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

.app-docs-content h4 {
    font-size: 10px !important;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary) !important;
    opacity: 0.7;
    margin-bottom: 10px;
}

.app-docs-content p {
    font-size: 14px;
    line-height: 1.72;
    color: #374151;
}

.app-docs-content .evidence-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.app-docs-content .evidence-list li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.65;
    color: #374151;
}

.app-docs-content .evidence-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.5;
}

.app-docs-content .refs-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.app-docs-content .refs-list li {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
    padding: 8px 0;
}

.app-docs-content .refs-list li+li {
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.app-docs-content .tech-note {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
    line-height: 1.65;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

/* ---- Safe Area Insets (notch / Dynamic Island) ---- */
@supports (padding: env(safe-area-inset-top)) {
    .app-bar {
        padding-top: env(safe-area-inset-top);
        height: calc(56px + env(safe-area-inset-top));
    }

    .app-mode-main {
        top: calc(56px + env(safe-area-inset-top));
    }

    .app-drawer {
        padding-top: env(safe-area-inset-top);
    }
}

/* ---- Desktop Refinements ---- */
@media (min-width: 768px) {
    .app-docs-modal {
        max-width: 560px;
        left: 50%;
        transform: translateX(-50%) translateY(100%);
        border-radius: 20px 20px 0 0;
    }

    .app-docs-modal.is-open {
        transform: translateX(-50%) translateY(0);
    }

    .app-drawer {
        width: 300px;
    }
}

/* =============================================
   ANIMATED APP TILES SYSTEM
   ============================================= */

.font-display {
    font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
}

/* Tile Card Container */
.app-tile-card {
    position: relative;
    border-radius: 28px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 24px -8px rgba(0, 0, 0, 0.06);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

.app-tile-card:hover {
    box-shadow: 0 32px 64px -16px rgba(0, 0, 0, 0.14),
        0 0 0 1px rgba(79, 70, 229, 0.06);
}

/* Animated Preview Canvas */
.tile-preview {
    position: relative;
    height: 180px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Shimmer sweep across preview */
.tile-preview::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.12) 50%,
            transparent 100%);
    animation: shimmerSweep 5s ease-in-out infinite;
    pointer-events: none;
    z-index: 5;
}

@keyframes shimmerSweep {

    0%,
    100% {
        left: -100%;
    }

    50% {
        left: 150%;
    }
}

/* Floating app icon badge — relative+margin to escape overflow clip */
.tile-icon-float {
    position: relative;
    z-index: 20;
    margin-top: -32px;
    margin-left: 24px;
    margin-bottom: 40px;
    /* Counteracts -32px top margin + 8px gap */
    width: fit-content;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-tile-card:hover .tile-icon-float {
    transform: translateY(-4px) scale(1.06);
}

.tile-icon-float img {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2), 0 0 0 3px white;
    background: white;
}

/* Tile Content area */
.tile-content {
    padding: 0 28px 28px;
}

/* Glow behind tile on hover */
.tile-glow {
    position: absolute;
    inset: -2px;
    border-radius: 30px;
    opacity: 0;
    transition: opacity 0.6s ease;
    z-index: -1;
    filter: blur(24px);
    pointer-events: none;
}

.app-tile-card:hover .tile-glow {
    opacity: 0.4;
}

/* Magnetic Button */
.magnetic-btn {
    position: relative;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ripple click effect */
.btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: rippleOut 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes rippleOut {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Clinical tool card animated icon */
.clinical-tool-card {
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.clinical-tool-card:hover .tool-icon-wrap {
    animation: gentleBounce 0.6s ease;
}

@keyframes gentleBounce {

    0%,
    100% {
        transform: translateY(0) rotate(0);
    }

    40% {
        transform: translateY(-8px) rotate(-3deg);
    }

    70% {
        transform: translateY(-2px) rotate(1deg);
    }
}

/* Showcase tile animated border */
.showcase-tile {
    position: relative;
}

.showcase-tile::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 32px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent, rgba(255, 255, 255, 0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
}

.showcase-tile:hover::before {
    opacity: 1;
}

/* Staggered tile entrance */
.tile-stagger {
    opacity: 0;
    transform: translateY(50px);
}

/* Button group layout for dual buttons */
.tile-btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tile-btn-single {
    display: grid;
    grid-template-columns: 1fr;
}

/* Mobile refinements for tiles */
@media (max-width: 768px) {
    .tile-preview {
        height: 150px;
    }

    .tile-content {
        padding: 0 24px 24px;
    }

    .tile-icon-float {
        margin-top: -24px;
        margin-left: 16px;
        margin-bottom: 32px;
        /* Counteracts -24px top margin + 8px gap */
        left: auto;
        bottom: auto;
    }

    .tile-icon-float img {
        width: 48px;
        height: 48px;
        border-radius: 14px;
    }
}