/* CSS Custom Properties */
:root {
    --cuttlefish-hue: 280;
    --primary-color: hsl(var(--cuttlefish-hue), 60%, 50%);
    --bg-color: #0a0e27;
    --text-color: #e0e6f0;
    --modal-bg: #1a1f3a;
    --modal-overlay: rgba(0, 0, 0, 0.85);
    --tentacle-base: #8b7fc7;
    --glow-color: #b8a9ff;

    --animation-duration: 3s;
    --transition-speed: 0.3s;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* Cuttlefish Container */
#cuttlefish-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#cuttlefish-container svg {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
}

/* Mobile: Make cuttlefish fill the width and be easily interactable */
@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
    }

    #cuttlefish-container {
        padding: 0;
        height: auto;
        min-height: 100vh;
        display: block;
    }

    #cuttlefish-container svg {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: none !important;
        display: block;
    }
}

/* Tentacle Styles (filled tapered shapes) */
.tentacle {
    cursor: pointer;
    fill: var(--tentacle-base);
    stroke: none;
    transition: filter var(--transition-speed) ease, fill var(--transition-speed) ease;
    transform-origin: center;
}

.tentacle:hover,
.tentacle:focus {
    filter: drop-shadow(0 0 12px var(--glow-color)) brightness(1.2);
    outline: none;
}

.tentacle:focus-visible {
    outline: 2px solid var(--glow-color);
    outline-offset: 4px;
}

/* Tentacle Labels */
.tentacle-label {
    fill: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    transition: fill var(--transition-speed) ease;
}

/* Mobile: Larger, more readable labels */
@media (max-width: 768px) {
    .tentacle-label {
        font-size: 18px;
        font-weight: 600;
    }
}

.tentacle-label:hover,
.tentacle-label:focus {
    fill: var(--glow-color);
    outline: none;
}

.tentacle-label:focus-visible {
    outline: 2px solid var(--glow-color);
    outline-offset: 4px;
}

/* Cuttlefish Body */
.cuttlefish-body {
    fill: hsl(var(--cuttlefish-hue), 60%, 50%);
    transition: fill 0.5s ease;
}

.cuttlefish-eye {
    fill: #1a1f3a;
}

.cuttlefish-eye-highlight {
    fill: rgba(255, 255, 255, 0.4);
}

.cuttlefish-fin {
    fill: hsl(var(--cuttlefish-hue), 55%, 45%);
    opacity: 0.8;
    transition: fill 0.5s ease;
}

/* New body elements from improved graphics */
.cuttlefish-head {
    fill: hsl(var(--cuttlefish-hue), 50%, 40%);
    transition: fill 0.5s ease;
}

.cuttlefish-stripe {
    stroke: hsl(var(--cuttlefish-hue), 40%, 20%);
    stroke-width: 2;
    fill: none;
    opacity: 0.4;
}

.cuttlefish-eye-outer {
    fill: #f5f5dc;
    stroke: hsl(var(--cuttlefish-hue), 40%, 25%);
    stroke-width: 1.5;
}

.cuttlefish-eye-pupil {
    fill: #1a1a2e;
}

.feeding-tentacle {
    opacity: 0.9;
}

/* Toggle Buttons */
.toggle-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--modal-bg);
    border: 2px solid var(--tentacle-base);
    color: var(--text-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: transform var(--transition-speed) ease, border-color var(--transition-speed) ease;
    z-index: 100;
}

/* List toggle button positioned above animation toggle */
.list-toggle {
    bottom: 80px;
}

/* Mobile: Larger touch target for toggle button */
@media (max-width: 768px) {
    .toggle-button {
        width: 60px;
        height: 60px;
        font-size: 24px;
        bottom: 15px;
        right: 15px;
    }
}

.toggle-button:hover {
    transform: scale(1.1);
    border-color: var(--glow-color);
}

.toggle-button:active {
    transform: scale(0.95);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    pointer-events: none;
}

.modal-overlay:not([hidden]) {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--modal-bg);
    border: 2px solid var(--tentacle-base);
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    position: relative;
    transform: scale(0.9);
    transition: transform var(--transition-speed) ease;
}

/* Mobile: Fixed modal sizing that works even when zoomed */
@media (max-width: 768px) {
    .modal-content {
        width: calc(100% - 40px);
        max-width: none;
        margin: 20px;
        padding: 25px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
}

.modal-overlay:not([hidden]) .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 30px;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    transition: color var(--transition-speed) ease;
}

.modal-close:hover {
    color: var(--glow-color);
}

.modal-title {
    margin-bottom: 15px;
    color: var(--glow-color);
    font-size: 24px;
}

.modal-description {
    margin-bottom: 20px;
    line-height: 1.6;
    color: var(--text-color);
}

.modal-link {
    display: inline-block;
    padding: 10px 20px;
    background: var(--tentacle-base);
    color: var(--text-color);
    text-decoration: none;
    border-radius: 6px;
    transition: background var(--transition-speed) ease, transform var(--transition-speed) ease;
}

/* Mobile: Larger, more readable modal text and touch-friendly buttons */
@media (max-width: 768px) {
    .modal-title {
        font-size: 28px;
        margin-bottom: 20px;
    }

    .modal-description {
        font-size: 18px;
        line-height: 1.7;
        margin-bottom: 25px;
    }

    .modal-link {
        padding: 15px 30px;
        font-size: 18px;
        width: 100%;
        text-align: center;
    }

    .modal-close {
        font-size: 40px;
        padding: 10px 15px;
        top: 5px;
        right: 5px;
    }
}

.modal-link:hover {
    background: var(--glow-color);
    transform: translateX(5px);
}

/* Animation States */
@keyframes tentacle-wave {
    0%, 100% {
        transform: rotate(0deg) translateX(0);
    }
    50% {
        transform: rotate(2deg) translateX(3px);
    }
}

.tentacle {
    animation: tentacle-wave var(--animation-duration) ease-in-out infinite;
}

.tentacle:nth-child(1) { animation-delay: 0s; }
.tentacle:nth-child(2) { animation-delay: 0.4s; }
.tentacle:nth-child(3) { animation-delay: 0.8s; }
.tentacle:nth-child(4) { animation-delay: 1.2s; }
.tentacle:nth-child(5) { animation-delay: 1.6s; }
.tentacle:nth-child(6) { animation-delay: 2s; }
.tentacle:nth-child(7) { animation-delay: 2.4s; }
.tentacle:nth-child(8) { animation-delay: 2.8s; }

/* Pause animation on hover */
.tentacle:hover {
    animation-play-state: paused;
}

/* Animation disabled state */
.animations-disabled * {
    animation: none !important;
    transition: none !important;
}

/* Paused state when modal is open */
.animation-paused .tentacle {
    animation-play-state: paused;
}

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

/* Error Message Styles */
.error-message {
    color: #ff6b6b;
    text-align: center;
    padding: 20px;
    font-size: 18px;
}

/* Loading State */
.loading {
    color: var(--text-color);
    text-align: center;
    padding: 20px;
    font-size: 18px;
}

/* List View Overlay */
.list-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    pointer-events: none;
}

.list-view:not([hidden]) {
    opacity: 1;
    pointer-events: all;
}

.list-view-content {
    background: var(--modal-bg);
    border: 2px solid var(--tentacle-base);
    border-radius: 12px;
    padding: 40px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.9);
    transition: transform var(--transition-speed) ease;
}

.list-view:not([hidden]) .list-view-content {
    transform: scale(1);
}

.list-view-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 30px;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    transition: color var(--transition-speed) ease;
}

.list-view-close:hover {
    color: var(--glow-color);
}

.list-view-content h1 {
    color: var(--glow-color);
    margin-bottom: 25px;
    font-size: 28px;
}

.site-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.site-list li {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(139, 127, 199, 0.3);
}

.site-list li:last-child {
    border-bottom: none;
}

.site-list a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    line-height: 1.6;
    transition: color var(--transition-speed) ease;
}

.site-list a:hover,
.site-list a:focus {
    color: var(--glow-color);
}

.site-list strong {
    font-size: 18px;
    color: var(--glow-color);
    display: block;
    margin-bottom: 5px;
}

/* Mobile: Adjust list view for smaller screens */
@media (max-width: 768px) {
    .list-view-content {
        width: calc(100% - 40px);
        max-width: none;
        margin: 20px;
        padding: 30px 25px;
        max-height: calc(100vh - 40px);
    }

    .list-view-content h1 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .site-list strong {
        font-size: 20px;
    }

    .site-list a {
        font-size: 16px;
    }

    .list-toggle {
        bottom: 85px;
    }
}
