/**
 * Fish Timer - Zhween Classroom Tools
 *
 * Modern ocean-themed countdown timer with animated fish
 * Supports RTL languages and dark mode
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    /* Brand Colors */
    --timer-primary: #15aebf;
    --timer-primary-hover: #0e9aa8;
    --timer-primary-light: rgba(21, 174, 191, 0.1);

    /* Ocean Colors */
    --timer-ocean-top: #3dd5ed;
    --timer-ocean-mid: #1ca2c0;
    --timer-ocean-bottom: #00464d;
    --timer-seaweed: #32CD32;
    --timer-coral: #FF6B6B;

    /* Surface Colors */
    --timer-bg: #f8fafc;
    --timer-surface: #ffffff;

    /* Text Colors */
    --timer-text: #1e293b;
    --timer-text-secondary: #64748b;
    --timer-text-muted: #94a3b8;

    /* Border & Dividers */
    --timer-border: #e2e8f0;
    --timer-border-light: #f1f5f9;

    /* Feedback Colors */
    --timer-success: #22c55e;

    /* Shadows */
    --timer-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --timer-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);

    /* Spacing */
    --timer-panel-width: 260px;
    --timer-gap: 1rem;
    --timer-radius: 12px;
    --timer-radius-sm: 8px;

    /* Transitions */
    --timer-transition: 150ms ease;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --timer-bg: #0f172a;
        --timer-surface: #1e293b;
        --timer-text: #f1f5f9;
        --timer-text-secondary: #94a3b8;
        --timer-text-muted: #64748b;
        --timer-border: #334155;
        --timer-border-light: #1e293b;
        --timer-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        --timer-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    }
}

/* ==========================================================================
   Base Container
   ========================================================================== */

.timer {
    display: flex;
    flex-direction: column;
    min-height: 95vh;
    height: 100%;
    background: var(--timer-bg);
    color: var(--timer-text);
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow-x: hidden;
}

/* ==========================================================================
   Body Layout
   ========================================================================== */

.timer__body {
    display: flex;
    flex: 1 1 auto;
    gap: var(--timer-gap);
    padding: var(--timer-gap);
    overflow: auto;
}

/* ==========================================================================
   Left Panel (Controls)
   ========================================================================== */

.timer__panel {
    width: var(--timer-panel-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
}

/* ==========================================================================
   Sections
   ========================================================================== */

.timer__section {
    background: var(--timer-surface);
    border-radius: var(--timer-radius);
    padding: 1rem;
    border: 1px solid var(--timer-border);
}

.timer__section--display {
    text-align: center;
    background: linear-gradient(135deg, var(--timer-primary) 0%, var(--timer-primary-hover) 100%);
    border: none;
    color: white;
}

.timer__section--actions {
    margin-top: auto;
}

.timer__section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--timer-primary);
    margin: 0 0 0.75rem 0;
}

.timer__section-title svg {
    opacity: 0.8;
}

/* ==========================================================================
   Time Inputs
   ========================================================================== */

.timer__time-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.timer__input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.timer__input-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--timer-text-secondary);
    text-transform: uppercase;
}

.timer__input-group input {
    width: 60px;
    padding: 0.5rem;
    border: 2px solid var(--timer-border);
    border-radius: var(--timer-radius-sm);
    background: var(--timer-surface);
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    color: var(--timer-text);
    transition: border-color var(--timer-transition), box-shadow var(--timer-transition);
}

.timer__input-group input:focus {
    outline: none;
    border-color: var(--timer-primary);
    box-shadow: 0 0 0 3px var(--timer-primary-light);
}

.timer__time-sep {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--timer-text-muted);
    margin-top: 1rem;
}

.timer__fish-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--timer-primary-light);
    border-radius: var(--timer-radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--timer-primary);
}

.timer__fish-info svg {
    opacity: 0.7;
}

/* ==========================================================================
   Timer Display
   ========================================================================== */

.timer__display {
    font-size: 2.5rem;
    font-weight: 900;
    font-family: 'Courier New', monospace;
    line-height: 1.2;
    direction: ltr;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.timer__remaining {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.timer__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--timer-radius-sm);
    cursor: pointer;
    transition: all var(--timer-transition);
}

.timer__btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.timer__btn--primary {
    background: var(--timer-primary);
    color: white;
}

.timer__btn--primary:hover:not(:disabled) {
    background: var(--timer-primary-hover);
    transform: translateY(-1px);
}

.timer__btn--secondary {
    background: var(--timer-border-light);
    color: var(--timer-text);
}

.timer__btn--secondary:hover:not(:disabled) {
    background: var(--timer-border);
}

.timer__btn--full {
    width: 100%;
}

.timer__btn-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.timer__btn-group .timer__btn {
    flex: 1;
}

/* ==========================================================================
   Main Content Area (Ocean)
   ========================================================================== */

.timer__main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.timer__ocean {
    flex: 1;
    position: relative;
    background: linear-gradient(
        to bottom,
        var(--timer-ocean-top) 0%,
        var(--timer-ocean-mid) 50%,
        var(--timer-ocean-bottom) 100%
    );
    border-radius: var(--timer-radius);
    overflow: hidden;
    border: 3px solid rgba(21, 174, 191, 0.4);
    min-height: 300px;
}

/* ==========================================================================
   Ocean Decorations
   ========================================================================== */

.timer__decorations {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

/* Seaweed */
.timer__seaweed {
    position: absolute;
    bottom: 0;
    width: clamp(14px, 2vw, 20px);
    background: linear-gradient(to top, #228B22, var(--timer-seaweed), #90EE90);
    border-radius: 50% 50% 0 0;
    animation: timer-sway 4s ease-in-out infinite;
    transform-origin: bottom center;
}

@keyframes timer-sway {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

/* Coral */
.timer__coral {
    position: absolute;
    bottom: 0;
    border-radius: 60% 60% 0 0;
    animation: timer-pulse 3s ease-in-out infinite;
}

.timer__coral--1 {
    left: 16%;
    width: 26px;
    height: 18px;
    background: radial-gradient(circle, var(--timer-coral), #FF4444);
}

.timer__coral--2 {
    right: 20%;
    width: 22px;
    height: 14px;
    background: radial-gradient(circle, #FF8E8E, #FF6666);
    animation-delay: 1s;
}

@keyframes timer-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ==========================================================================
   Bubbles
   ========================================================================== */

.timer__bubbles {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.timer__bubble {
    position: absolute;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(255,255,255,0.3));
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.3);
    animation: timer-float 4s infinite ease-in-out;
}

@keyframes timer-float {
    0% {
        transform: translateY(100%) scale(0);
        opacity: 0;
    }
    10% { opacity: 1; }
    90% { opacity: 0.6; }
    100% {
        transform: translateY(-100%) scale(1.2);
        opacity: 0;
    }
}

/* ==========================================================================
   Fish
   ========================================================================== */

.timer__fish {
    position: absolute;
    width: clamp(40px, 5vw, 55px);
    height: clamp(26px, 3.5vw, 38px);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
    z-index: 5;
    animation: timer-swim 3s ease-in-out infinite;
}

.timer__fish svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

@keyframes timer-swim {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(5px) rotate(1deg); }
    75% { transform: translateX(-5px) rotate(-1deg); }
}

.timer__fish--disappear {
    transform: scale(0) rotate(360deg) !important;
    opacity: 0;
}

.timer__fish:hover {
    transform: scale(1.15);
    filter: brightness(1.1);
}

/* ==========================================================================
   Completion Overlay
   ========================================================================== */

.timer__overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.timer__overlay--visible {
    display: flex;
}

.timer__overlay-content {
    background: var(--timer-surface);
    padding: 2rem;
    border-radius: var(--timer-radius);
    text-align: center;
    box-shadow: var(--timer-shadow-lg);
    animation: timer-pop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 320px;
    width: 100%;
}

.timer__overlay-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.timer__overlay-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--timer-primary);
    margin: 0 0 0.5rem 0;
}

.timer__overlay-text {
    color: var(--timer-text-secondary);
    margin: 0 0 1.5rem 0;
}

@keyframes timer-pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 900px) {
    .timer__body {
        flex-direction: column;
    }

    .timer__panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .timer__section {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 150px;
    }

    .timer__section--actions {
        flex-basis: 100%;
        margin-top: 0;
    }

    .timer__ocean {
        min-height: 250px;
    }
}

@media (max-width: 600px) {
    :root {
        --timer-panel-width: 100%;
        --timer-gap: 0.75rem;
    }

    .timer__section {
        flex-basis: 100%;
    }

    .timer__time-inputs {
        gap: 0.25rem;
    }

    .timer__input-group input {
        width: 50px;
        font-size: 1rem;
    }

    .timer__display {
        font-size: 2rem;
    }

    .timer__btn-group {
        flex-wrap: wrap;
    }

    .timer__btn-group .timer__btn {
        flex: 1 1 auto;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .timer__fish,
    .timer__bubble,
    .timer__seaweed,
    .timer__coral {
        animation: none;
    }

    .timer__fish--disappear {
        transition: opacity 0.3s ease;
    }

    .timer__overlay-content {
        animation: none;
    }
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="rtl"] .timer__display {
    direction: ltr;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .timer__panel,
    .timer__overlay {
        display: none !important;
    }

    .timer__body {
        display: block;
        padding: 0;
    }

    .timer__ocean {
        page-break-inside: avoid;
    }
}
