/**
 * style.css - Split-Flap Display Styles for Clackboard
 *
 * Dark mode, high contrast split-flap display with mechanical aesthetic.
 * V2: Realistic split-flap with top/bottom letter sections using background-position method.
 */

/* ========================================
   RESET & BASE STYLES
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #0a0a0a;
    --card-bg: #1a1a1a;
    --text-color: #e0e0e0;
    --accent-color: #f39c12;  /* Amber - classic split-flap look */
    --accent-hover: #e67e22;
    --border-color: #333;
    --input-bg: #252525;
    --success-color: #27ae60;
    --danger-color: #c0392b;
    --flap-bg: #111;
    --flap-text: #fff;
    --flap-active: #f39c12;
}

body {
    font-family: 'Courier New', monospace;  /* Monospace for mechanical feel */
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* ========================================
   LAYOUT UTILITIES
   ======================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.full-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.center-box {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* ========================================
   BUTTONS & INPUTS
   ======================================== */

.btn {
    display: inline-block;
    padding: 12px 24px;
    background-color: var(--accent-color);
    color: #000;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: #555;
    color: #fff;
}

.btn-secondary:hover {
    background-color: #666;
}

.btn-danger {
    background-color: var(--danger-color);
    color: #fff;
}

.btn-danger:hover {
    background-color: #a93226;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color);
}

input[type="range"] {
    width: 100%;
    height: 8px;
    background: var(--input-bg);
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
}

/* ========================================
   FORMS
   ======================================== */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
    color: var(--accent-color);
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

/* ========================================
   CARDS
   ======================================== */

.card {
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
}

.card-header {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.card-header h2 {
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ========================================
   NAVIGATION
   ======================================== */

nav {
    background-color: var(--card-bg);
    border-bottom: 2px solid var(--border-color);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav .logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 3px;
}

nav .nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

nav a:hover {
    color: var(--accent-color);
}

/* ========================================
   DASHBOARD STYLES
   ======================================== */

.board-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.board-card {
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.board-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
}

.board-card h3 {
    color: var(--accent-color);
    margin-bottom: 10px;
}

.board-card .board-stats {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 15px;
}

.board-card .board-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.board-card .board-actions .btn {
    flex: 1;
    text-align: center;
}

.board-card .public-url {
    background-color: var(--input-bg);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    word-break: break-all;
    margin-bottom: 10px;
    color: #888;
}

/* ========================================
   ALERTS & MESSAGES
   ======================================== */

.alert {
    padding: 15px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-success {
    background-color: rgba(39, 174, 96, 0.2);
    border: 2px solid var(--success-color);
    color: #a8e6cf;
}

.alert-error {
    background-color: rgba(192, 57, 43, 0.2);
    border: 2px solid var(--danger-color);
    color: #f5b7b1;
}

.alert-info {
    background-color: rgba(52, 152, 219, 0.2);
    border: 2px solid #3498db;
    color: #aed6f1;
}

/* ========================================
   SPLIT-FLAP DISPLAY V2 - REALISTIC SPLIT-FLAP
   BACKGROUND-POSITION METHOD
   ======================================== */

.split-flap-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    overflow: hidden;
}

.flap-display {
    display: grid;
    gap: var(--flap-gap, 1vmin);
    padding: 2vmin;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    justify-content: center;
    align-content: center;
    /* Grid template will be set dynamically via JavaScript */
}

/* Individual flap container */
.flap {
    /* All dimensions will be set dynamically via JavaScript */
    background: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 100%);
    border: 3px solid var(--border-color);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    /* Border width scales with flap size */
    border-width: 0.5vmin;
    perspective: 600px;  /* Enable 3D perspective for flip animations */
}

/* Flap container for the top half (flips down) */
.flap-top-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    z-index: 2;
    transform-style: preserve-3d;
    transform-origin: bottom;  /* Pivot from bottom edge */
    background: linear-gradient(180deg, #1a1a1a 0%, #151515 100%);
    border-bottom: 2px solid #000;
    overflow: hidden;
}

/* Flap container for the bottom half (static during top flip) */
.flap-bottom-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    z-index: 1;
    background: linear-gradient(180deg, #0f0f0f 0%, #0a0a0a 100%);
    overflow: hidden;
}

/* Character display elements - SVG background images */
.flap-char-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* SVG background will be set via JavaScript */
    /* backgroundPosition: 'center 0px' shows top half */
    /* backgroundPosition: 'center -<half-height>px' shows bottom half */
    /* No clip-path needed - handled by background-position */
}

.flap-char-bottom {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* SVG background will be set via JavaScript */
    /* backgroundPosition: 'center 0px' shows top half */
    /* backgroundPosition: 'center -<half-height>px' shows bottom half */
    /* No clip-path needed - handled by background-position */
}

/* Animation classes */
.flap-top-container.flipping {
    animation: flipTopDown 0.2s ease-in-out forwards;
}

@keyframes flipTopDown {
    0% {
        transform: rotateX(0deg);
    }
    100% {
        transform: rotateX(-180deg);
    }
}

/* Bottom half flip animation (for revealing new character after top completes) */
.flap-bottom-container.revealing {
    animation: revealBottom 0.1s ease-in-out forwards;
}

@keyframes revealBottom {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* Mechanical lighting effect */
.flap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.03) 50%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 10;
}

/* Space for wide characters */
.flap.space {
    /* Width will be set dynamically (smaller than regular flaps) */
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    /* Flap dimensions are now responsive, set dynamically by JavaScript */
    /* No hardcoded sizes needed */

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .board-card .board-actions {
        flex-direction: column;
    }

    nav {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    nav .nav-links {
        justify-content: center;
    }
}

/* ========================================
   MODAL
   ======================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
}

.modal-header h3 {
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

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