@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Outfit:wght@300;400;700&family=Noto+Sans+TC:wght@300;500;900&display=swap');

:root {
    --moda-accent: #6868ac;
    --moda-glow: rgba(104, 104, 172, 0.2);
    --crystal-bg: rgba(255, 255, 255, 0.5);
    --ui-text: #1e1e3f;
}

/* Accessibility: Ensure text can be zoomed */
html {
    font-size: 100%; /* Allow browser zoom */
}

body {
    font-family: 'Outfit', 'Noto Sans TC', sans-serif;
    background-color: #f4f7f9;
    color: var(--ui-text);
    margin: 0;
    overflow-x: hidden;
    height: 100vh;
    /* Prevent text size adjustment on mobile */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Accessibility: Screen reader only - Handled by Tailwind */

/* Accessibility: Focus visible for keyboard navigation */
.focus\:not-sr-only:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: inherit !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

#three-canvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: block;
}

.crystal-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-top: 5px solid var(--moda-accent);
    box-shadow: 0 8px 32px rgba(104, 104, 172, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
    position: relative;
}

.hud-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: var(--moda-accent);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 700;
}

.watermark {
    position: absolute;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10vw;
    color: rgba(104, 104, 172, 0.04);
    font-weight: 900;
    user-select: none;
    pointer-events: none;
    white-space: nowrap;
}

.info-chip {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 4px 16px rgba(104, 104, 172, 0.08);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.info-chip:hover {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(16px) saturate(200%);
    -webkit-backdrop-filter: blur(16px) saturate(200%);
    border-color: rgba(104, 104, 172, 0.3);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(104, 104, 172, 0.15), 0 4px 12px rgba(0, 0, 0, 0.06);
}

.social-node {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(104, 104, 172, 0.1);
    color: var(--moda-accent);
    transition: all 0.3s ease;
}

.social-node:hover {
    background: var(--moda-accent);
    color: #ffffff;
    transform: scale(1.1) rotate(3deg);
}

.reveal {
    animation: crystalReveal 1.2s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes crystalReveal {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cursor::after {
    content: '_';
    animation: blink 1s infinite;
    color: var(--moda-accent);
}

@keyframes blink {
    50% { opacity: 0; }
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.offline-badge {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 165, 0, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 60;
}

#error-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    display: none;
}

.error-message {
    background: white;
    border: 2px solid #ef4444;
    border-radius: 1rem;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    color: #ef4444;
    font-weight: 700;
    max-width: 90%;
    width: 400px;
    box-sizing: border-box;
}

.error-message button {
    min-width: 120px;
    min-height: 44px;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

@media (max-width: 640px) {
    .error-message {
        padding: 2rem 1.5rem;
        max-width: 95%;
        width: auto;
    }

    .error-message button {
        width: 100%;
        min-height: 48px;
    }
}

#notification-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notification {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    font-size: 0.875rem;
    font-weight: 600;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-info {
    border-left: 4px solid #3b82f6;
    color: #3b82f6;
}

.notification-warning {
    border-left: 4px solid #f59e0b;
    color: #f59e0b;
}

.notification-success {
    border-left: 4px solid #10b981;
    color: #10b981;
}

.notification-error {
    border-left: 4px solid #ef4444;
    color: #ef4444;
}

.warning-banner {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}
.warning-banner i {
  width: 20px;
  height: 20px;
}

@media (max-width: 768px) {
    .watermark {
        font-size: 15vw;
    }

    #notification-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .notification {
        font-size: 0.75rem;
        padding: 0.75rem 1rem;
    }
}

/* ========================================
   3D Card Flip - Bilingual Support
   ======================================== */

/* 3D 翻轉容器 */
.card-perspective {
    perspective: 2000px;
    width: 100%;
    max-width: 56rem; /* 896px */
    padding: 0 1rem;
    margin: 0 auto;
}

/* 卡片內層（可翻轉） */
.card-inner {
    position: relative;
    width: 100%;
    min-height: 600px;

    /* 3D 變換 */
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;

    /* GPU 加速 */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);

    /* 翻轉動畫 */
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: transform;
    cursor: pointer;
}

/* 翻轉狀態 */
.card-inner.is-flipped {
    transform: rotateY(180deg) translateZ(0);
    -webkit-transform: rotateY(180deg) translateZ(0);
}

/* Desktop: side flip for realistic effect */
@media (min-width: 1024px) {
    /* 桌面版實體名片比例 */
    .card-perspective {
        max-width: 540px;
        aspect-ratio: 540 / 856;
        margin: 4rem auto;
    }

    .card-inner {
        transform-origin: center right;

        /* 使用 CSS 變數 */
        --rotate-x: 0deg;
        --rotate-y: 0deg;
        transform: rotateY(var(--rotate-y)) rotateX(var(--rotate-x)) translateZ(0);
        -webkit-transform: rotateY(var(--rotate-y)) rotateX(var(--rotate-x)) translateZ(0);
    }

    .card-inner.is-flipped {
        transform: translateX(-100%) rotateY(calc(var(--rotate-y) - 180deg)) rotateX(var(--rotate-x)) translateZ(0);
        -webkit-transform: translateX(-100%) rotateY(calc(var(--rotate-y) - 180deg)) rotateX(var(--rotate-x)) translateZ(0);
    }

    /* Hover 效果：移除 translateY，避免與 3D 傾斜衝突 */
    /* .card-inner:hover {
        transform: translateY(-4px) translateZ(0);
    }

    .card-inner.is-flipped:hover {
        transform: translateX(-100%) rotateY(-180deg) translateY(-4px) translateZ(0);
    } */

    /* 白色邊框 */
    .card-face {
        border: 8px solid #fff;

        /* 4 層陰影系統 */
        box-shadow:
            0 0 0 1px rgba(0,0,0,0.05),
            0 2px 4px rgba(0,0,0,0.05),
            0 8px 16px rgba(0,0,0,0.1),
            0 30px 60px -10px rgba(0,0,0,0.2),
            inset 0 1px 0 0 rgba(255,255,255,0.5);

        transition: box-shadow 0.3s ease;
    }

    /* Hover 效果：陰影增強 */
    .card-inner:hover .card-face {
        box-shadow:
            0 0 0 1px rgba(0,0,0,0.08),
            0 4px 8px rgba(0,0,0,0.08),
            0 16px 32px rgba(0,0,0,0.15),
            0 50px 100px -15px rgba(0,0,0,0.3),
            inset 0 1px 0 0 rgba(255,255,255,0.5);
    }

    /* 桌面版字體放大 */
    /* 姓名 */
    #user-name,
    #user-name-en {
        font-size: 3.5rem; /* text-6xl: 3.75rem, 調整為 3.5rem */
        line-height: 1;
    }

    /* 職稱 */
    #user-title,
    #user-title-en {
        font-size: 1rem; /* text-base */
        line-height: 1.5rem;
    }

    /* 部門 */
    #user-department,
    #user-department-en {
        font-size: 1rem; /* text-base */
        line-height: 1.5rem;
    }

    /* HUD 文字 */
    .hud-text {
        font-size: 0.75rem; /* text-xs */
        line-height: 1rem;
    }

    /* 資訊晶片 */
    .info-chip {
        font-size: 1rem; /* text-base */
        line-height: 1.5rem;
    }

    /* Typewriter 文字 */
    #typewriter,
    #typewriter-en {
        font-size: 1.25rem; /* text-xl */
        line-height: 1.75rem;
    }
}

/* ========================================
   物理互動效果 (Desktop Only)
   ======================================== */

/* 輕微浮動動畫 */
@keyframes cardFloating {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-5px); }
}

/* 點擊彈跳動畫 */
@keyframes cardBounce {
    0%   { transform: scale(1); }
    30%  { transform: scale(0.95); }
    60%  { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@media (min-width: 1024px) {
    /* 浮動：套用在 perspective 容器，不干涉 card-inner 的 3D transform */
    .card-perspective {
        animation: cardFloating 3s ease-in-out infinite;
    }

    /* Hover 時暫停浮動，啟動放大 */
    .card-perspective:hover {
        animation-play-state: paused;
        transform: scale(1.05);
        transition: transform 0.3s ease-out;
        z-index: 20;
    }

    /* Bounce 時暫停浮動，由 JS 添加此 class */
    .card-perspective.is-bouncing {
        animation-play-state: paused;
        animation: cardBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }
}

/* 卡片正反面 */
.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;

    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scrolling from watermark */
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable both-edges;

    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;

    /* Physical card standard radius (16px ≈ 6mm) */
    border-radius: 1rem;

    /* Gradient background */
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.8) 0%,
        rgba(255, 255, 255, 0.6) 100%);

    /* Enhanced blur effect */
    backdrop-filter: blur(40px) saturate(180%) brightness(110%);
    -webkit-backdrop-filter: blur(40px) saturate(180%) brightness(110%);

    /* Multi-layer shadow with inner highlight */
    box-shadow:
        0 4px 16px 0 rgba(104, 104, 172, 0.08),
        0 1px 4px 0 rgba(0, 0, 0, 0.04),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.5);

    /* Refined border */
    border: 0.5px solid rgba(255, 255, 255, 0.15);

    /* Accent color band */
    border-top: 4px solid var(--moda-accent);
}

/* 隱藏 Webkit 滾動條 */
.card-face::-webkit-scrollbar {
    display: none;
}

/* 正面 */
.card-front {
    z-index: 2;
    transform: rotateY(0deg) translateZ(1px);
    -webkit-transform: rotateY(0deg) translateZ(1px);
}

/* 背面 */
.card-back {
    z-index: 1;
    transform: rotateY(180deg) translateZ(1px);
    -webkit-transform: rotateY(180deg) translateZ(1px);
}

/* 焦點指示器（WCAG 合規） */
.card-inner:focus {
    outline: none;
}

.card-inner:focus-visible {
    outline: 2px solid var(--moda-accent);
    outline-offset: 4px;
    border-radius: 1rem;
}

/* 浮動提示 */
#hint-badge {
    animation: float 3s ease-in-out infinite;
}

#hint-badge button {
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* 響應式調整 */
@media (max-width: 640px) {
    .card-perspective {
        max-width: 100%;
        padding: 0 0.5rem;
    }
    
    .card-inner {
        min-height: 500px;
    }
}
