/* ============================================================
   ORCSGirls Play Lab — Shared Styles
   ============================================================ */

/* --- Design Tokens (aligned with orcsgirls.org branding) --- */
:root {
    --primary-purple:  #2d1b4e;   /* deep brand purple */
    --accent-green:    #00873c;   /* brand green */
    --accent-magenta:  #c2185b;   /* accent / highlight */
    --accent-teal:     #0097a7;   /* secondary accent */
    --bg-light:        #f5f3f8;   /* soft purple-tinted background */
    --text-dark:       #1a1a2e;
    --text-muted:      #5a5470;
    --card-shadow:     0 6px 24px rgba(45,27,78,0.10);
    --radius:          12px;
    --radius-sm:       6px;

    /* kept as aliases so tool CSS still works */
    --primary-navy:    var(--primary-purple);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* --- Base --- */
body {
    font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Main content grows to push footer to bottom on every page */
body > main,
body > .dp-page-wrap { flex: 1; }

h1, h2, h3, .logo {
    font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
    font-weight: 700;
}

img, canvas { max-width: 100%; height: auto; }

footer {
    text-align: center;
    padding: 10px 15px;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid #e0d8f0;
    margin-top: 0;
    flex-shrink: 0;
}

/* --- Layout --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    width: 100%;
}

/* Tool pages: give main a small top padding so content clears the header edge */
body > main.container {
    padding-top: 12px;
    padding-bottom: 8px;
}

/* ============================================================
   SITE HEADER — single unified bar (logo + title + nav)
   ============================================================ */
.site-header {
    background: var(--primary-purple);
    border-bottom: 3px solid var(--accent-green);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-top: 8px;
    padding-bottom: 8px;
    flex-wrap: wrap;
}

/* Logo */
.nav-logo {
    height: 44px;
    width: auto;
    flex-shrink: 0;
}

/* Page title — sits between logo and nav */
.header-title {
    font-family: 'Montserrat', system-ui, sans-serif;
    font-weight: 700;
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: white;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: -0.3px;
}

/* Spacer pushes nav to the right */
.header-spacer { flex: 1; }

/* Nav links */
.nav-links {
    list-style: none;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}

.nav-links a {
    text-decoration: none;
    color: rgba(255,255,255,0.82);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 20px;
    transition: background 0.18s, color 0.18s;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.nav-links a:hover {
    background: rgba(255,255,255,0.12);
    color: white;
}

.nav-links a.active {
    background: var(--accent-green);
    color: white;
}

/* Vertical divider between logo/title and nav area */
.header-divider {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.2);
    flex-shrink: 0;
}

/* ============================================================
   Cards & Panels
   ============================================================ */
.panel {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 18px 20px;
    border-top: 4px solid var(--accent-teal);
    margin-bottom: 16px;
    width: 100%;
    overflow-x: auto;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.tool-card {
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 40px rgba(45,27,78,0.15);
}

.tool-card h3 {
    margin: 10px 0 15px;
    font-size: 1.4rem;
    color: var(--primary-purple);
    letter-spacing: -0.5px;
}

.tool-card p {
    color: var(--text-muted);
    flex-grow: 1;
    margin-bottom: 30px;
    font-size: 0.95rem;
    line-height: 1.7;
}

.tool-card .btn-launch { margin-top: auto; }

.card-label {
    font-size: 0.7rem;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-launch,
.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    min-height: 46px;
    width: 100%;
    background: var(--accent-green);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-align: center;
    text-transform: uppercase;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.btn-launch:hover, .nav-btn:hover { opacity: 0.88; }

.btn-launch:disabled,
.nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none !important;
    color: #888 !important;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
    width: 100%;
}

.btn-group .btn-launch { flex: 1 1 calc(50% - 10px); margin-top: 0; }

.btn-outline-teal {
    background: transparent !important;
    color: var(--accent-teal) !important;
    box-shadow: inset 0 0 0 2px var(--accent-teal) !important;
}

.btn-solid-teal {
    background: var(--accent-teal) !important;
    color: white !important;
    box-shadow: none !important;
}

/* ============================================================
   Tool Split Layout
   ============================================================ */
.tool-split,
.range-split {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
    align-items: stretch;
}

/* Controls column: flex column so the inner panel can grow to fill height */
.tool-side-controls {
    display: flex;
    flex-direction: column;
}

/* The panel inside the controls column fills its column and scrolls if needed */
.tool-side-controls .panel {
    flex: 1;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Visual column also stretches — canvas/content centred inside */
.tool-side-visual {
    display: flex;
    flex-direction: column;
}

.tool-side-controls,
.tool-side-visual,
.range-controls,
.range-visual,
.trans-panel,
.trans-panel-center { flex: 1 1 100%; min-width: 0; }

/* ============================================================
   Form Elements
   ============================================================ */
input, textarea, select {
    width: 100%;
    padding: 12px;
    border: 1px solid #d5cce8;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-family: monospace;
    font-size: 1rem;
    box-sizing: border-box;
    max-width: 100%;
    background: #fdfcff;
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--accent-green);
    border-color: var(--accent-green);
}

input[type="range"] {
    padding: 0;
    background: transparent;
    border: none;
}

/* ============================================================
   Loader Spinner
   ============================================================ */
.loader {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--accent-magenta);
    border-radius: 50%;
    width: 14px;
    height: 14px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (min-width: 768px) {
    .tool-side-controls { flex: 1; }
    .range-controls { flex: 0 0 200px; }
    .tool-side-visual,   .range-visual   { flex: 2; }
}

@media (min-width: 850px) {
    .trans-container { flex-wrap: nowrap !important; }
    .trans-panel { flex: 1 !important; }
    .trans-panel-center { flex: 0.6 !important; min-width: 200px !important; }
}

@media (max-width: 768px) {
    .site-header .container { gap: 10px; }
    .header-title { font-size: 0.95rem; }
    .panel { min-width: 100% !important; padding: 15px; }
    .canvas-container { flex-direction: column; align-items: center; }
}

@media (max-width: 520px) {
    .header-divider { display: none; }
    .header-title { display: none; }   /* logo alone on very small screens */
    .nav-links a { font-size: 0.78rem; padding: 4px 8px; }
}

/* ============================================================
   Theme Toggle Switch
   ============================================================ */
.theme-switch {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
    margin-left: 8px;
}

.theme-switch input { display: none; }

.switch-icon { font-size: 0.9rem; line-height: 1; }

.switch-track {
    width: 38px;
    height: 22px;
    background: rgba(255,255,255,0.2);
    border-radius: 11px;
    position: relative;
    transition: background 0.25s;
    border: 1.5px solid rgba(255,255,255,0.25);
    flex-shrink: 0;
}

.switch-knob {
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

html[data-theme="dark"] .switch-track {
    background: var(--accent-teal);
    border-color: var(--accent-teal);
}

html[data-theme="dark"] .switch-knob { transform: translateX(16px); }

/* ============================================================
   Dark / Night Mode
   ============================================================ */
html[data-theme="dark"] {
    --primary-purple: #a070f0;
    --bg-light:       #120d1e;
    --text-dark:      #e8e4f0;
    --text-muted:     #9b90b8;
    --card-shadow:    0 6px 24px rgba(0,0,0,0.5);
}

html[data-theme="dark"] .site-header { background: #2d1b4e; }

html[data-theme="dark"] .panel { background: #1e1630; border-color: #2d1f4a; }

html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: #261b3d;
    border-color: #4a3870;
    color: var(--text-dark);
}

html[data-theme="dark"] footer { border-top-color: #2d1f4a; color: var(--text-muted); }

/* Science */
html[data-theme="dark"] .canvas-group { background: #1e1630; }
html[data-theme="dark"] .data-dashboard { background: #1e1630; border-left-color: var(--accent-teal); }
html[data-theme="dark"] .obs-guide,
html[data-theme="dark"] .info-box { background: #1a1535; }
html[data-theme="dark"] .skin-tone-example-box { background: #1a1535; }

/* Web — Unicode grid */
html[data-theme="dark"] .unicode-grid {
    background: #1e1630;
    border-color: #3d2d5a;
}
html[data-theme="dark"] .char-tile {
    background: #261b3d;
    border-color: #3d2d5a;
}
html[data-theme="dark"] .char-tile:hover { background: #3d2d5a; }

/* Web — Emoji page */
html[data-theme="dark"] .emoji-ref-table th {
    background: #2d1f4a;
    color: var(--text-dark);
    border-bottom-color: #4a3870;
}
html[data-theme="dark"] .emoji-ref-table td { border-bottom-color: #2d1f4a; }
html[data-theme="dark"] .emoji-ref-table tr:hover td { background: #261b3d; }
html[data-theme="dark"] .current-code-box { background: #1a1535; border-left-color: var(--accent-teal); }
html[data-theme="dark"] .current-code-box code { color: #f48fb1; }

/* Cyber — Vigenère table */
html[data-theme="dark"] .v-table td { border-color: #2d2050; }
html[data-theme="dark"] .header-cell { background: #2d2050; color: var(--text-dark); }
html[data-theme="dark"] .highlight-row { background: rgba(0,151,167,0.25); }
html[data-theme="dark"] .highlight-col { background: rgba(194,24,91,0.25); }

/* Tool cards */
html[data-theme="dark"] .tool-card h3 { color: var(--text-dark); }
html[data-theme="dark"] .tool-card p  { color: var(--text-muted); }

/* Stats box */
html[data-theme="dark"] .stats-box { color: var(--text-dark); }


/* ============================================================
   HAMBURGER NAV — collapses on narrow screens
   ============================================================ */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    margin-left: auto;
}

.nav-hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: transform 0.22s, opacity 0.22s;
}

/* Animate to X when open */
.nav-hamburger.open span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

@media (max-width: 900px) {
    .nav-hamburger { display: flex; }
    .header-spacer  { display: none; }

    /* Nav links become dropdown panel */
    #nav-links {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        background: var(--primary-purple);
        border-top: 2px solid var(--accent-green);
        border-bottom-left-radius: 10px;
        border-bottom-right-radius: 10px;
        padding: 8px 12px 12px;
        flex-direction: column;
        gap: 4px;
        min-width: 160px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.3);
        z-index: 200;
    }

    #nav-links.open { display: flex; }

    #nav-links li { width: 100%; }
    #nav-links a   { display: block; width: 100%; border-radius: 6px; }

    /* Header needs relative so the dropdown is positioned correctly */
    .site-header { position: sticky; top: 0; }
    .site-header .container { position: relative; flex-wrap: nowrap; }

    /* Keep theme switch always visible, right of hamburger */
    .theme-switch { order: 2; margin-left: 8px; }
    .nav-hamburger { order: 1; }
}

/* ============================================================
   CARD EMOJI — big emoji in top-right of tool cards
   ============================================================ */
.tool-card { position: relative; overflow: hidden; }

.card-emoji {
    position: absolute;
    top: 12px;
    right: 14px;
    font-size: 2.8rem;
    line-height: 1;
    opacity: 0.55;
    pointer-events: none;
    user-select: none;
    filter: saturate(1.2);
}

/* ============================================================
   FOOTER LINK
   ============================================================ */
footer a {
    color: var(--text-muted);
    text-decoration: underline;
}
footer a:hover { color: var(--primary-purple); }
html[data-theme="dark"] footer a { color: var(--text-muted); }
html[data-theme="dark"] footer a:hover { color: var(--accent-teal); }

/* ============================================================
   STANDALONE MODE  (?mode=standalone)
   Hide navigation so students can't wander to other sections.
   The logo, page title and theme switch remain visible.
   ============================================================ */
html[data-standalone] .nav-links,
html[data-standalone] .nav-hamburger,
html[data-standalone] .header-divider {
    display: none !important;
}

html[data-standalone] .header-spacer {
    display: none !important;
}

/* Keep logo left-aligned and title visible in standalone */
html[data-standalone] .site-header .container {
    justify-content: flex-start;
    gap: 12px;
}

/* ============================================================
   FOOTER — contact info
   ============================================================ */
.footer-contact {
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.footer-contact a {
    color: var(--accent-teal);
    text-decoration: none;
}

.footer-contact a:hover {
    text-decoration: underline;
}

html[data-theme="dark"] .footer-contact a {
    color: var(--accent-teal);
}
