﻿/* ============================================================================
   CSS CUSTOM PROPERTIES (Design System)
   ============================================================================ */
:root {
    /* Colors */
    --color-primary: #ffd800;
    --color-primary-dark: #1a1a18;
    --color-white: #fefefe;
    --color-text: #1a1a18;
    --color-text-light: #333;
    --color-border: #ddd;
    --color-border-light: #eee;
    --color-shadow-light: rgba(0, 0, 0, 0.1);
    --color-shadow-medium: rgba(0, 0, 0, 0.15);
    --color-shadow-dark: rgba(0, 0, 0, 0.26);
    --color-backdrop: rgba(0, 0, 0, 0.5);
    
    /* Spacing Scale (base 8px) */
    --sp-xs: 0.25rem;    /* 4px */
    --sp-sm: 0.5rem;     /* 8px */
    --sp-md: 1rem;       /* 16px */
    --sp-lg: 1.5rem;     /* 24px */
    --sp-xl: 2rem;       /* 32px */
    --sp-2xl: 2.5rem;    /* 40px */
    --sp-3xl: 3rem;      /* 48px */
    
    /* Typography */
    --font-family-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-size-base: 1rem;
    --line-height-tight: 1.4;
    --line-height-normal: 1.6;
    --line-height-relaxed: 1.8;
    
    /* Responsive Typography Scale (using clamp) */
    --font-h1: clamp(1.75rem, 5vw, 2rem);
    --font-h2: clamp(1.5rem, 4vw, 1.75rem);
    --font-h3: clamp(1.25rem, 3vw, 1.5rem);
    --font-h4: clamp(1.125rem, 2.5vw, 1.25rem);
    --font-h5: clamp(1rem, 2vw, 1.125rem);
    --font-h6: clamp(0.875rem, 1.5vw, 1rem);
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Transitions */
    --transition-fast: 0.15s ease-in-out;
    --transition-normal: 0.3s ease-in-out;
    --transition-slow: 0.5s ease-in-out;
    
    /* Layout Constraints */
    --layout-max-width: 1400px;
    --layout-gutter: clamp(0.75rem, 2vw, 1.875rem);
    
    /* Touch Target Minimum */
    --touch-target-min: 2.75rem; /* 44px */
}

/* ============================================================================
   UNIVERSAL STYLES & OVERFLOW PREVENTION
   ============================================================================ */
html,
body {
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: var(--font-family-system);
    background-color: #fff;
    color: var(--color-text);
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

img,
svg,
iframe,
video {
    max-width: 100%;
    height: auto;
    display: block;
}


/* ============================================================================
   NAVIGATION STYLES (Mobile-First, Capability-Driven)
   ============================================================================ */
nav {
    background-color: var(--color-primary-dark);
    box-shadow: 0 0.125rem 0.25rem var(--color-shadow-light);
    position: relative;
    z-index: 999;
}

.nav-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--sp-md);
    height: var(--touch-target-min);
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* Desktop Navigation - Hidden by Default (Mobile-First) */
#desktop-nav {
    display: none;
    flex: 1;
    gap: var(--sp-sm);
    align-items: center;
}

/* Show desktop nav only with hover capability */
@media (hover: hover) and (pointer: fine) {
    #desktop-nav {
        display: flex;
    }
}

#desktop-nav a {
    color: var(--color-primary);
    text-decoration: none;
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
    font-size: 0.875rem;
    white-space: nowrap;
    border-bottom: 0.1875rem solid transparent;
    display: flex;
    align-items: center;
    min-height: var(--touch-target-min);
}

@media (hover: hover) {
    #desktop-nav a:hover {
        background-color: rgba(255, 216, 0, 0.1);
        border-bottom-color: var(--color-primary);
    }
}

#desktop-nav img {
    margin-right: var(--sp-xs);
    width: 1.125rem;
    height: 1.125rem;
}

/* ============================================================================
   MENU TOGGLE BUTTON (Mobile/Touch)
   ============================================================================ */
#menu-toggle {
    display: flex;
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    padding: var(--sp-sm);
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    position: relative;
    z-index: 1001;
    transition: opacity var(--transition-fast), display var(--transition-fast);
}

#menu-toggle img {
    width: 1.75rem;
    height: 1.75rem;
    display: block;
}

/* Show menu toggle on mobile (JavaScript will handle desktop overflow logic) */
@media (max-width: 992px) {
    #menu-toggle {
        display: flex;
    }
}

@media (hover: hover) {
    #menu-toggle:hover {
        opacity: 0.8;
    }
}

@media (pointer: coarse) {
    #menu-toggle:active {
        opacity: 0.8;
    }
}

/* ============================================================================
   MOBILE MENU (Touch-Optimized)
   ============================================================================ */
#mobile-menu {
    position: fixed;
    top: var(--touch-target-min);
    right: 0;
    left: auto;
    background-color: var(--color-white);
    box-shadow: -2px 2px 10px 0 rgba(0,0,0,0.26);
    border-radius: 0 0 2px 2px;
    min-width: 220px;
    max-width: 90vw;
    max-height: calc(100vh - var(--touch-target-min));
    overflow-y: auto;
    display: none;
    flex-direction: column;
    z-index: 1000;
}

#mobile-menu.active {
    display: flex;
}

#mobile-menu a {
    color: var(--color-text);
    display: flex;
    align-items: center;
    padding: var(--sp-md) var(--sp-lg);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border-light);
    transition: background-color var(--transition-normal);
    white-space: nowrap;
    font-size: 0.875rem;
    min-height: var(--touch-target-min);
}

@media (pointer: coarse) {
    #mobile-menu a:active {
        background-color: var(--color-primary);
        color: var(--color-text);
    }
}

@media (hover: hover) {
    #mobile-menu a:hover {
        background-color: var(--color-primary);
        color: var(--color-text);
    }
}

#mobile-menu img {
    margin-right: var(--sp-md);
    width: 1.25rem;
    height: 1.25rem;
}

/* ============================================================================
   CLOCK AND USER INFO
   ============================================================================ */
.nav-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: var(--sp-md);
    margin-left: auto;
}

#helsinki-clock,
.clock-display {
    color: var(--color-primary);
    font-size: clamp(0.65rem, 1.5vw, 0.875rem);
    font-weight: 700;
    white-space: nowrap;
    margin: 0;
    display: block;
}

.clock-timezone {
    color: var(--color-white);
    font-size: clamp(0.6rem, 1.2vw, 0.75rem);
    white-space: nowrap;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    color: var(--color-primary);
    font-size: clamp(0.8rem, 1.5vw, 0.875rem);
}

/* Hide clock on very small screens */
@media (max-width: 28rem) {
    #helsinki-clock {
        display: none;
    }
}


/* ============================================================================
   MAIN CONTENT & LAYOUT
   ============================================================================ */
main {
    padding: var(--layout-gutter);
    min-height: calc(100vh - var(--touch-target-min));
}

.container {
    width: 100%;
    max-width: var(--layout-max-width);
    margin: 0 auto;
    padding: 0;
}

/* Responsive Container Sizing */
@media (min-width: 64rem) {
    .container {
        width: 90%;
    }
}

@media (min-width: 87.5rem) {
    .container {
        width: 85%;
    }
}

/* ============================================================================
   MODAL & DETAILS (Touch-Optimized)
   ============================================================================ */
.mobile-details-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--color-backdrop);
    z-index: 1001;
    overflow-y: auto;
}

.mobile-details-modal.active {
    display: flex;
    flex-direction: column;
}

.mobile-details-modal-content {
    background-color: var(--color-white);
    margin-top: auto;
    padding: var(--sp-lg);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 85vh;
    min-height: 60vh;
    overflow-y: auto;
}


/* ============================================================================
   TABLES & FORMS (Responsive, Content-Aware)
   ============================================================================ */
table {
    border-collapse: collapse;
    width: 100%;
    margin: var(--sp-lg) 0;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
}

table th,
table td {
    padding: clamp(0.5rem, 1.5vw, 1rem);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    height: auto;
    min-height: 2.5rem;
    display: table-cell;
}

table th {
    background-color: var(--color-primary);
    color: var(--color-text);
    font-weight: bold;
    position: sticky;
    top: 0;
}

table tbody tr {
    transition: background-color var(--transition-normal);
}

@media (hover: hover) {
    table tbody tr:hover {
        background-color: rgba(255, 216, 0, 0.08);
        transform: translateX(0.125rem);
    }
}

/* Table Cell Alignment */
td.col-expand,
th[data-column="expand"] {
    width: 2.5rem;
    padding: 0;
    text-align: center;
}

td.col-expand img.expand-icon,
th[data-column="expand"] img.expand-icon {
    vertical-align: middle;
    display: inline-block;
    width: 1.125rem;
    height: 1.125rem;
}

/* Table Action Cells - Responsive */
td.col-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--sp-sm);
    flex-wrap: wrap;
    white-space: normal;
}

/* Forms - Mobile-First */
form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-lg);
    width: 100%;
}

.input-field {
    display: flex;
    flex-direction: column;
    gap: var(--sp-xs);
    width: 100%;
}

.input-field label {
    color: var(--color-text);
    font-weight: 500;
    font-size: clamp(0.8rem, 1.5vw, 0.875rem);
}

.input-field input,
.input-field textarea,
.input-field select {
    padding: var(--sp-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    font-family: inherit;
    min-height: var(--touch-target-min);
    width: 100%;
    box-sizing: border-box;
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.input-field input:focus,
.input-field textarea:focus,
.input-field select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.125rem rgba(255, 216, 0, 0.1);
}


/* ============================================================================
   BUTTONS (Touch-Friendly, Capability-Driven)
   ============================================================================ */
button,
.btn,
.btn-small,
.btn-large {
    padding: clamp(0.5rem, 1.5vw, 0.75rem) clamp(0.75rem, 2vw, 1rem);
    border: none;
    border-radius: var(--radius-md);
    font-size: clamp(0.8rem, 1.5vw, 0.875rem);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: inherit;
    font-weight: 500;
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

button,
button.btn,
.btn {
    background-color: var(--color-primary);
    color: var(--color-text);
    padding: 0.6em 1.2em;
    border: 1px solid transparent;
    border-radius: 0.25em;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    transition: all 0.2s ease-in;
    white-space: nowrap;
}

@media (hover: hover) {
    button:hover,
    .btn:hover {
        opacity: 0.9;
        transform: translateY(-0.0625rem);
        box-shadow: 0 0.25rem 0.5rem var(--color-shadow-light);
    }
}

@media (pointer: coarse) {
    button:active,
    .btn:active {
        opacity: 0.85;
        transform: translateY(0);
    }
}

button:focus,
button:focus-visible,
.btn:focus,
.btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 0.125rem;
}

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

.btn-small {
    padding: clamp(0.4rem, 1vw, 0.6rem) clamp(0.6rem, 1.5vw, 0.8rem);
    font-size: clamp(0.75rem, 1.3vw, 0.8rem);
}

.btn-large {
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 2.5vw, 1.25rem);
    font-size: clamp(0.9rem, 1.7vw, 1rem);
}


/* ============================================================================
   TYPOGRAPHY (Fluid, Responsive with clamp())
   ============================================================================ */
h1, h2, h3, h4, h5, h6 {
    color: var(--color-text);
    margin: var(--sp-lg) 0 var(--sp-md) 0;
    line-height: var(--line-height-tight);
    font-weight: 600;
}

h1 { font-size: var(--font-h1); }
h2 { font-size: var(--font-h2); }
h3 { font-size: var(--font-h3); }
h4 { font-size: var(--font-h4); }
h5 { font-size: var(--font-h5); }
h6 { font-size: var(--font-h6); }

p {
    color: var(--color-text-light);
    line-height: var(--line-height-normal);
    margin: var(--sp-md) 0;
    font-size: clamp(0.9rem, 1.5vw, 1rem);
}

small {
    font-size: clamp(0.75rem, 1.2vw, 0.875rem);
}

strong {
    font-weight: 600;
}


/* ============================================================================
   CARDS & SECTIONS (Container Query Ready)
   ============================================================================ */
.card {
    border-radius: var(--radius-lg);
    box-shadow: 0 0.125rem 0.5rem var(--color-shadow-light);
    border: 1px solid rgba(255, 216, 0, 0.15);
    transition: all var(--transition-normal);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (hover: hover) {
    .card:hover {
        box-shadow: 0 0.25rem 1rem var(--color-shadow-medium);
        border-color: rgba(255, 216, 0, 0.25);
    }
}

.card-content {
    padding: clamp(var(--sp-md), 3vw, var(--sp-xl));
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    word-wrap: break-word;
    flex: 1;
}

/* Card Grid - Uses auto-fit for responsive layout */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
    gap: var(--sp-lg);
    width: 100%;
}

/* Responsive Row Layout */
.row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-lg);
    width: 100%;
    margin: var(--sp-lg) 0;
}

.col {
    flex: 1 1 100%;
    min-width: 0;
}

/* Flexible column sizing */
.col-2 { flex-basis: calc(50% - var(--sp-md)); }
.col-3 { flex-basis: calc(33.333% - var(--sp-lg)); }
.col-4 { flex-basis: calc(25% - var(--sp-lg)); }

@media (max-width: 36rem) {
    .col-2,
    .col-3,
    .col-4 {
        flex-basis: 100%;
    }
}


/* ============================================================================
   UTILITIES & HELPERS (Responsive, CSS Variable Based)
   ============================================================================ */

/* Text Alignment */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

/* Responsive Margin Utilities */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--sp-sm); }
.mt-2 { margin-top: var(--sp-md); }
.mt-3 { margin-top: var(--sp-lg); }
.mt-4 { margin-top: var(--sp-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--sp-sm); }
.mb-2 { margin-bottom: var(--sp-md); }
.mb-3 { margin-bottom: var(--sp-lg); }
.mb-4 { margin-bottom: var(--sp-xl); }

.mx-auto { margin-left: auto; margin-right: auto; }
.my-auto { margin-top: auto; margin-bottom: auto; }

/* Responsive Padding Utilities */
.p-0 { padding: 0; }
.p-1 { padding: var(--sp-sm); }
.p-2 { padding: var(--sp-md); }
.p-3 { padding: var(--sp-lg); }
.p-4 { padding: var(--sp-xl); }

.px-1 { padding-left: var(--sp-sm); padding-right: var(--sp-sm); }
.px-2 { padding-left: var(--sp-md); padding-right: var(--sp-md); }
.px-3 { padding-left: var(--sp-lg); padding-right: var(--sp-lg); }

.py-1 { padding-top: var(--sp-sm); padding-bottom: var(--sp-sm); }
.py-2 { padding-top: var(--sp-md); padding-bottom: var(--sp-md); }
.py-3 { padding-top: var(--sp-lg); padding-bottom: var(--sp-lg); }

/* Display Utilities */
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none; }
.visible { display: auto; }

/* Flex Utilities */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

/* Gap Utilities */
.gap-1 { gap: var(--sp-sm); }
.gap-2 { gap: var(--sp-md); }
.gap-3 { gap: var(--sp-lg); }
.gap-4 { gap: var(--sp-xl); }

/* Width/Height */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* Border Utilities */
.border { border: 1px solid var(--color-border); }
.border-top { border-top: 1px solid var(--color-border); }
.border-bottom { border-bottom: 1px solid var(--color-border); }
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }

/* Shadow Utilities */
.shadow-sm { box-shadow: 0 0.125rem 0.25rem var(--color-shadow-light); }
.shadow { box-shadow: 0 0.25rem 0.5rem var(--color-shadow-light); }
.shadow-lg { box-shadow: 0 0.5rem 1rem var(--color-shadow-medium); }

/* Color Utilities */
.text-primary { color: var(--color-primary); }
.text-dark { color: var(--color-text); }
.bg-primary { background-color: var(--color-primary); }
.bg-dark { background-color: var(--color-primary-dark); }
.bg-white { background-color: var(--color-white); }

/* Overflow */
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
.overflow-visible { overflow: visible; }

/* Vertical Alignment */
.align-top { vertical-align: top; }
.align-middle { vertical-align: middle; }
.align-bottom { vertical-align: bottom; }


/* ============================================================================
   RESPONSIVE ADJUSTMENTS (Content-Based Breakpoints Only)
   ============================================================================ */

/* Small Screens: Extra-small adjustments */
@media (max-width: 24rem) {
    main {
        padding: var(--sp-sm);
    }
    
    .nav-info {
        gap: var(--sp-sm);
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .col-2,
    .col-3,
    .col-4 {
        flex-basis: 100%;
    }
}

/* Medium Screens: Tablet and landscape phones */
@media (min-width: 36rem) and (max-width: 64rem) {
    main {
        padding: var(--sp-lg);
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    }
}

/* Large Screens: Desktops */
@media (min-width: 64rem) {
    main {
        padding: var(--sp-2xl);
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    }
}

/* Extra Large Screens: Large desktops */
@media (min-width: 87.5rem) {
    main {
        padding: var(--sp-3xl);
    }
}

/* ============================================================================
   ORIENTATION-SPECIFIC STYLES
   ============================================================================ */
@media (orientation: landscape) and (max-height: 30rem) {
    main {
        padding: var(--sp-sm);
    }
    
    .container {
        max-width: 100%;
    }
}

/* ============================================================================
   HIGH RESOLUTION DISPLAYS (Retina)
   ============================================================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ============================================================================
   DARK MODE SUPPORT (Future Enhancement)
   ============================================================================ */
@media (prefers-color-scheme: dark) {
    /* Future dark mode styles */
}

/* ============================================================================
   REDUCED MOTION (Accessibility)
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */
@media print {
    nav,
    #menu-toggle,
    #mobile-menu,
    button,
    .btn {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    main {
        padding: 0;
        min-height: auto;
    }
    
    a {
        text-decoration: underline;
    }
}
