/* style.css - キミは何の博士？ 〜ふしぎなAI図鑑〜 */

:root {
    /* Color Palette - Vibrant & Kids Friendly */
    --primary: #FF6B6B;      /* Friendly Red/Pink */
    --primary-light: #FF8E8E;
    --primary-dark: #FF4757;
    
    --secondary: #4ECDC4;    /* Magical Teal */
    --secondary-light: #8DE0DA;
    --secondary-dark: #3BB1A9;
    
    --accent: #FFE66D;       /* Star Gold */
    --accent-dark: #FFD13B;
    
    --bg-color: #F7F9FC;     /* Soft Light Blue/Gray Background */
    --card-bg: #FFFFFF;
    
    --text-main: #2F3542;
    --text-muted: #747D8C;
    --text-light: #FFFFFF;
    
    --danger: #FF4757;
    --success: #2ED573;
    
    --shadow-sm: 0 4px 6px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 15px rgba(0,0,0,0.1);
    --shadow-lg: 0 15px 30px rgba(0,0,0,0.15);
    --shadow-glow: 0 0 20px rgba(255, 230, 109, 0.6);
    
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 30px;
    --radius-pill: 50px;
    
    --font-main: 'M PLUS Rounded 1c', sans-serif;
    
    --transition-fast: 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-bounce: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow: hidden; /* Prevent scrolling on body, handled inside views */
    touch-action: manipulation;
}

.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Mobile browser height fix */
    overflow: hidden;
    background: linear-gradient(135deg, #F0F4FF 0%, #E6E8FF 100%);
}

/* Material Symbols config */
.material-symbols-rounded {
    font-size: 28px;
    vertical-align: middle;
}

/* ----------------------------------
   Views & Navigation
---------------------------------- */
.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 10;
    background: transparent;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.view.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.98);
}

.view.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 80px 20px 80px 20px; /* Space for absolute header on top */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header */
header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 50;
    border-bottom: 2px solid rgba(0,0,0,0.05);
}

header h1 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary-dark);
}

header.hidden {
    display: none;
}

/* ----------------------------------
   Buttons
---------------------------------- */
button {
    font-family: var(--font-main);
    font-weight: 700;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition-bounce);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:active {
    transform: scale(0.95);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 16px 32px;
    border-radius: var(--radius-pill);
    font-size: 1.2rem;
    box-shadow: 0 8px 0 var(--primary-dark), 0 15px 20px rgba(255, 107, 107, 0.4);
    margin-bottom: 8px; /* For the thick 3D border */
    position: relative;
    top: 0;
}

.btn-primary:active {
    top: 6px;
    box-shadow: 0 2px 0 var(--primary-dark), 0 5px 10px rgba(255, 107, 107, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--secondary-dark);
    padding: 14px 28px;
    border-radius: var(--radius-pill);
    font-size: 1.1rem;
    border: 3px solid var(--secondary);
    box-shadow: 0 6px 0 var(--secondary-dark), var(--shadow-md);
    margin-bottom: 6px;
    position: relative;
    top: 0;
}

.btn-secondary:active {
    top: 4px;
    box-shadow: 0 2px 0 var(--secondary-dark), var(--shadow-sm);
}

.icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    color: var(--text-main);
    box-shadow: var(--shadow-md);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 10px;
}

.btn-outline {
    background: transparent;
    color: var(--secondary-dark);
    border: 2px solid var(--secondary);
    padding: 10px 20px;
    border-radius: var(--radius-pill);
}

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    box-shadow: 0 4px 0 #d63031;
}

.btn-danger-text {
    background: transparent;
    color: var(--danger);
    padding: 10px 20px;
}

.pulse-anim {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 8px 0 var(--primary-dark), 0 0 0 0 rgba(255, 107, 107, 0.7); }
    70% { box-shadow: 0 8px 0 var(--primary-dark), 0 0 0 15px rgba(255, 107, 107, 0); }
    100% { box-shadow: 0 8px 0 var(--primary-dark), 0 0 0 0 rgba(255, 107, 107, 0); }
}

/* ----------------------------------
   Home View
---------------------------------- */
.home-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    position: relative;
    z-index: 20;
}

.title-logo {
    margin-bottom: 50px;
    position: relative;
    animation: float 4s ease-in-out infinite;
}

.sub-title {
    font-size: 1.1rem;
    color: var(--secondary-dark);
    font-weight: 800;
    margin-bottom: 5px;
    display: block;
    text-shadow: 1px 1px 0px white;
}

.main-title {
    font-size: 2.8rem;
    line-height: 1.2;
    color: var(--primary);
    font-weight: 900;
    text-shadow: 
        -2px -2px 0 white,  
         2px -2px 0 white,
        -2px  2px 0 white,
         2px  2px 0 white,
         0 5px 15px rgba(255,107,107,0.3);
}

.sparkles {
    position: absolute;
    top: -10px;
    right: -20px;
    font-size: 2rem;
    animation: twinkle 1.5s infinite alternate;
}

.main-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 320px;
    margin-bottom: 40px;
}

/* Background Shapes */
.bg-shape {
    position: absolute;
    z-index: 1;
    opacity: 0.5;
}
.circle-1 {
    width: 200px; height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    top: -50px; left: -50px;
}
.circle-2 {
    width: 300px; height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--secondary-light) 0%, transparent 70%);
    bottom: -100px; right: -50px;
}
.star-1 { top: 20%; right: 10%; font-size: 2rem; transform: rotate(15deg); }
.star-2 { bottom: 30%; left: 10%; font-size: 2.5rem; transform: rotate(-10deg); }

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}
@keyframes twinkle {
    0% { opacity: 0.4; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1.2); }
}

/* ----------------------------------
   Camera View
---------------------------------- */
.camera-container {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
    width: 100%;
    border-radius: 0 0 24px 24px;
}

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.target-box {
    width: 250px;
    height: 250px;
    border: 4px dashed rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    box-shadow: 0 0 0 2000px rgba(0,0,0,0.3); /* Dim surround */
    animation: target-pulse 2s infinite;
}

.camera-instruction {
    margin-top: 30px;
    color: white;
    font-weight: 800;
    font-size: 1.2rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.4);
    padding: 8px 16px;
    border-radius: var(--radius-pill);
}

.camera-back-btn {
    position: absolute;
    top: 20px;
    left: 15px;
    z-index: 100;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

@keyframes target-pulse {
    0% { transform: scale(1); border-color: rgba(255,255,255,0.5); }
    50% { transform: scale(1.05); border-color: var(--accent); }
    100% { transform: scale(1); border-color: rgba(255,255,255,0.5); }
}

.camera-controls {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 20px;
    background: white;
}

.shutter-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: white;
    border: 6px solid var(--primary);
    box-shadow: 0 0 0 4px white, inset 0 0 0 4px white, inset 0 0 20px rgba(0,0,0,0.2), var(--shadow-md);
    transition: all 0.1s;
}
.shutter-btn:active {
    transform: scale(0.9);
    background: var(--primary-light);
}

.hidden-input {
    display: none;
}
.btn-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}

/* ----------------------------------
   Appraisal View (Loading)
---------------------------------- */
#view-appraisal {
    background: linear-gradient(135deg, var(--secondary-dark), var(--primary-dark));
    color: white;
}
.appraisal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.scanner-anim {
    width: 200px;
    height: 200px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.2);
    margin-bottom: 40px;
    position: relative;
    overflow: hidden;
    border: 4px solid white;
    box-shadow: var(--shadow-glow);
}

#preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: sepia(0.5) hue-rotate(-30deg) saturate(1.5);
    opacity: 0.8;
}

.scan-line {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

.loading-text {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 15px;
}
.loading-subtext {
    font-size: 1.1rem;
    opacity: 0.9;
    text-align: center;
}

.dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* ----------------------------------
   Card Design
---------------------------------- */
.item-card {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 340px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 8px solid #FFE66D;
    display: flex;
    flex-direction: column;
    position: relative;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,230,109,0.1) 10px, rgba(255,230,109,0.1) 20px);
}

.card-header {
    padding: 15px;
    text-align: center;
    background: linear-gradient(to bottom, rgba(255,255,255,0.9), rgba(255,255,255,0.4));
}

.card-rarity {
    color: var(--accent-dark);
    font-size: 1.8rem;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 5px;
}

.card-name {
    font-size: 1.6rem;
    color: var(--text-main);
    font-weight: 900;
    line-height: 1.3;
    word-break: break-word; /* Prevent text overflow */
}

.card-image-box {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #000;
    border-top: 4px solid var(--accent);
    border-bottom: 4px solid var(--accent);
    overflow: hidden;
}

.card-image-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-body {
    padding: 15px 20px 20px;
    background: white;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-desc {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.5;
    word-break: break-word;
}

.card-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: auto; /* Push to bottom */
    padding-top: 15px;
    text-align: right;
}

.result-actions {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 320px;
}

/* ----------------------------------
   Encyclopedia Grid
---------------------------------- */
.encyclopedia-stats {
    background: white;
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    font-weight: 800;
    color: var(--secondary-dark);
}

.stat-num {
    font-size: 1.2rem;
    color: var(--primary);
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    width: 100%;
}

.grid-item {
    background: white;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 3px solid #FFE66D;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.grid-item:active {
    transform: scale(0.95);
}

.grid-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-bottom: 2px solid #FFE66D;
}

.grid-info {
    padding: 8px;
    text-align: center;
}

.grid-rarity {
    color: var(--accent-dark);
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.grid-name {
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 60px;
    font-weight: 700;
    line-height: 1.6;
}

.empty-icon {
    font-size: 4rem;
    color: var(--secondary-light);
    margin-bottom: 10px;
}

.empty-state.hidden {
    display: none;
}

/* ----------------------------------
   Modal
---------------------------------- */
.modal {
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-backdrop {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    z-index: 20;
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.close-btn {
    position: absolute;
    top: -60px;
    right: 0;
}

.detail-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    background: white;
    padding: 20px;
    border-radius: var(--radius-md);
}

/* ----------------------------------
   Settings Forms
---------------------------------- */
.settings-card {
    background: white;
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 400px;
    margin-bottom: 20px;
}

.settings-card h2 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--text-main);
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 700;
}

input[type="password"], input[type="text"] {
    padding: 12px 15px;
    border-radius: 8px;
    border: 2px solid #E2E8F0;
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

input[type="password"]:focus {
    border-color: var(--secondary);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.danger-zone {
    border: 2px dashed rgba(255, 71, 87, 0.3);
    background: rgba(255, 71, 87, 0.05);
}

/* ----------------------------------
   Toast Component
---------------------------------- */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(47, 53, 66, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    z-index: 9999;
    transition: transform var(--transition-bounce), opacity var(--transition-fast);
    opacity: 0;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ----------------------------------
   Responsive Tweaks
---------------------------------- */
@media (min-width: 600px) {
    .app-container {
        max-width: 414px; /* iPhone Max width */
        height: 850px;
        margin: 20px auto;
        border-radius: 40px;
        box-shadow: 0 30px 60px rgba(0,0,0,0.15);
        border: 8px solid white;
    }
}
