/* DESIGN SYSTEM VARIABLES */
:root {
    --bg-color: #e7e7e7; 
    --text-color: #333333; 
    --ui-bg: #1a1a1a;    /* Mørk footer/ticker i Light Mode */
    --ui-text: #e7e7e7;
    --news-bg: #e7e7e7;  /* Subtil grå for nyhetsbakgrunn */
    --hot-color: #8B0000;
    --local-color: #2c3e50;
    --box-width: 280px; 
    --transition: 0.3s ease;
}

body.dark-mode { 
    --bg-color: #1a1a1a; 
    --text-color: #e7e7e7; 
    --ui-bg: #e7e7e7;    /* Lys footer/ticker i Dark Mode */
    --ui-text: #1a1a1a;
    --news-bg: #222222;
}

/* BASE ARCHITECTURE */
body {
    background-color: var(--bg-color); 
    color: var(--text-color);
    font-family: 'Oswald', sans-serif; 
    margin: 0; 
    padding: 0;
    height: 100vh; 
    display: flex; 
    flex-direction: column;
    text-transform: uppercase; 
    transition: background-color var(--transition); 
    overflow: hidden;
}

/* UI INTERFACE ELEMENTS */
.utility-btn { position: absolute; top: 40px; left: 40px; cursor: pointer; z-index: 100; }
.cube-switch {
    --dx: 0px; /* mouse movement delta X */
    --dy: 0px; /* mouse movement delta Y */
    width: 36px;
    height: 36px;
    /* Default (light mode): slightly darker droplet */
    background: linear-gradient(180deg, rgba(0,0,0,0.12), rgba(0,0,0,0.06));
    border-radius: 50% 50% 50% 50% / 55% 55% 45% 45%;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    border: 1px solid rgba(0,0,0,0.18);
    display: inline-block;
    transform-origin: 50% 60%;
    transition: transform 180ms cubic-bezier(.2,.9,.2,1), box-shadow 160ms ease, border-radius 220ms ease;
    position: relative;
    overflow: visible;
}

/* Inner highlight */
.cube-switch::after {
    content: '';
    position: absolute;
    left: 12%;
    top: 8%;
    width: 40%;
    height: 40%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.95), rgba(255,255,255,0.2) 40%, transparent 60%);
    border-radius: 50%;
    pointer-events: none;
    filter: blur(0.2px);
}

/* Hover: simulate dragging finger through liquid by stretching towards mouse offset */
.cube-switch:hover {
    box-shadow: 0 12px 30px rgba(0,0,0,0.22);
}

.cube-switch:hover {
    /* amplify the pull effect by scaling and using amplified mouse offsets */
    transform: translate(calc(var(--mx, 0px) * 1.6), calc(var(--my, 0px) * 1.6)) scale(1.12) skewX(calc(var(--mx, 0px) / 8));
    border-radius: 45% 42% 68% 35% / 68% 42% 48% 35%;
}

/* Directional morph based on mouse movement delta */
.cube-switch.hover-follow { transition: transform 140ms cubic-bezier(.2,.9,.2,1); }

/* Click: splash morph animation */
.cube-switch.splash { animation: splash-morph 650ms cubic-bezier(.2,.9,.2,1); }

/* Pressed visual state: looks pushed down while mouse is held */
.cube-switch.pressed {
    transform: translateY(3px) scale(0.98);
    box-shadow: 0 4px 10px rgba(0,0,0,0.14);
    border-radius: 46% 44% 70% 34% / 70% 44% 46% 34%;
}

@keyframes splash-morph {
    0% {
        transform: translate(var(--dx,0),var(--dy,0)) scale(1) ;
        border-radius: 50% 50% 50% 50% / 55% 55% 45% 45%;
        box-shadow: 0 10px 26px rgba(0,0,0,0.22);
    }
    40% {
        transform: translate(calc(var(--dx,0) * 0.6), calc(var(--dy,0) * 0.6)) scale(1.25) skewX(-6deg);
        border-radius: 40% 60% 50% 50% / 40% 60% 50% 50%;
    }
    70% {
        transform: translate(calc(var(--dx,0) * -0.1), calc(var(--dy,0) * -0.2)) scale(0.95) skewX(4deg);
        border-radius: 50% 40% 60% 50% / 55% 36% 62% 48%;
    }
    100% {
        transform: translate(0,0) scale(1);
        border-radius: 50% 50% 50% 50% / 55% 55% 45% 45%;
        box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    }
}

/* Dark-mode visual tweak */
/* Dark-mode: make droplet lighter for contrast */
body.dark-mode .cube-switch { background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0.06)); border:1px solid rgba(255,255,255,0.16); }
.cube-switch::after { transition: opacity 180ms ease, transform 220ms ease; }
body.dark-mode .cube-switch::after { background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.98), rgba(255,255,255,0.45) 40%, transparent 60%); }
.hamburger { position: absolute; top: 40px; right: 40px; width: 24px; height: 16px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; z-index: 100; }
.hamburger span { display: block; width: 100%; height: 1px; background-color: var(--text-color); }

/* MAIN CLOCK DISPLAY - PERFECT ALIGNMENT */
.main-content { flex: 1; display: flex; justify-content: center; align-items: center; }
.container { width: var(--box-width); display: flex; flex-direction: column; gap: 10px; position: relative; }
#ampm-display { position: absolute; right: 0; top: -15px; font-size: 0.7rem; font-weight: bold; }

.row { 
    display: flex; 
    width: 100%; 
    justify-content: space-between; /* Låser bredden til 280px */
    line-height: 0.85; 
}

#time { font-size: 4.8rem; }
#time span { width: 35px; text-align: center; }

#day { 
    font-size: 2rem; 
    font-weight: 700; 
    
    padding: 5px 0;
    margin: 5px 0;
}
#day span { flex: 1; text-align: center; }

#date { font-size: 2.2rem; }
#date span { width: 28px; text-align: center; }

/* WALL STREET TICKER (MARKET DATA) */
#market-cards-container {
    width: 100%;
    background: var(--ui-bg); /* Invertert farge for fokus */
    color: var(--ui-text);
    padding: 10px 0;
    border-top: 2px solid var(--text-color);
    overflow: hidden;
    white-space: nowrap;
}

.market-track {
    display: inline-block;
    padding-left: 100%;
    animation: ticker-scroll 35s linear infinite;
}

.market-item {
    display: inline-flex;
    align-items: center;
    margin-right: 50px;
    font-family: 'Oswald', sans-serif;
}

.market-item span { font-size: 0.8rem; opacity: 0.7; margin-right: 10px; }
.market-item strong { font-size: 1.1rem; margin-right: 10px; }
.market-item small { font-size: 0.9rem; font-weight: bold; }

/* Financial Indicators */
.up { color: #009e00 !important; } /* Wall Street Green */
.down { color: #ff3131 !important; } /* Wall Street Red */

/* NEWS SYSTEM STRCTURE */
.bottom-area { width: 100%; }
.marquee-container { flex: 1; overflow: hidden; white-space: nowrap; }

/* LOCAL FEED */
#local-news-area { background: var(--local-color); color: white; display: flex; align-items: center; padding: 5px 0; }
.local-label { background: white; color: var(--local-color); padding: 0 10px; font-weight: bold; font-size: 0.7rem; margin-right: 10px; z-index: 5; }

/* HOT NEWS */
#hot-news-area { background: var(--hot-color); color: white; display: flex; align-items: center; padding: 8px 0; }
.hot-label { background: black; color: white; padding: 0 15px; font-weight: bold; font-size: 0.75rem; animation: flash 1s step-end infinite; z-index: 5; }

/* GLOBAL NEWS - REFINED LIGHTNESS */
.news-container { 
    padding: 12px 0; 
    overflow: hidden; 
    white-space: nowrap; 
    border-top: 1px solid var(--text-color);
    background-color: var(--news-bg);
    transition: background-color var(--transition);
}

#local-marquee { display: inline-block; padding-left: 100%; animation: scroll 60s linear infinite; }
#hot-marquee { display: inline-block; padding-left: 100%; animation: scroll 80s linear infinite; }
#news-marquee { display: inline-block; padding-left: 100%; animation: scroll 240s linear infinite; }

/* ANIMATIONS */
@keyframes ticker-scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }
@keyframes scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }
@keyframes flash { 50% { opacity: 0.5; } }

/* INTERACTION */
#market-cards-container:hover .market-track,
.bottom-area:hover #local-marquee, 
.bottom-area:hover #hot-marquee, 
.bottom-area:hover #news-marquee { 
    animation-play-state: paused; 
}

/* DYNAMIC FOOTER */
footer { 
    padding: 15px 0; 
    text-align: center; 
    font-size: 0.65rem; 
    letter-spacing: 2px; 
    background-color: var(--ui-bg); 
    color: var(--ui-text);
    font-weight: 700;
    transition: background-color var(--transition), color var(--transition);
}

/* TOOLBOX & SETTINGS */
#toolbox { 
    position: fixed; 
    top: 0; 
    right: 40px; 
    width: 200px; 
    background: var(--ui-bg); 
    color: var(--ui-text); 
    padding: 20px; 
    transform: translateY(-100%); 
    transition: 0.4s ease; 
    z-index: 200; 
    border: 1px solid var(--ui-text); 
}

#toolbox.open { transform: translateY(0); }

#toolbox select { 
    width: 100%; 
    background: transparent; 
    color: inherit; 
    border: 1px solid var(--ui-text); 
    padding: 8px; 
    margin-top: 10px; 
    font-family: inherit;
    text-transform: uppercase;
}

/* Make the Sources link match the FEATURES label style inside the toolbox */
#sources-link {
    font-weight: 700;
    color: var(--ui-text);
    text-decoration: none;
    font-family: inherit;
    display: inline-block;
    margin-left: 4px;
    font-size: inherit; /* match surrounding label size */
    text-transform: inherit; /* follow toolbox label casing */
    line-height: 1.1;
}

#close-btn {
    width: 100%;
    margin-top: 15px;
    padding: 10px;
    background: var(--ui-text);
    color: var(--ui-bg);
    border: none;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
}

footer { 
    padding: 15px 0; 
    display: flex;             /* Aktiverer flexbox */
    justify-content: center;    /* Sentrerer alt horisontalt */
    align-items: center;        /* Sentrerer alt vertikalt (flagg + tekst) */
    gap: 8px;                  /* Bestemmer avstanden mellom tekst og flagg */
    
    font-size: 0.65rem; 
    letter-spacing: 2px; 
    background-color: var(--ui-bg); 
    color: var(--ui-text);
    font-weight: 700;
    transition: background-color var(--transition), color var(--transition);
}

.footer-flag {
    display: block;            /* Fjerner uønsket mellomrom under bildet */
    opacity: 0.8;              /* Gjør det litt mer diskret som du ønsket */
    height: auto;              /* Beholder proporsjoner */
}

/* Footer link style */
.footer-link {
    color: var(--ui-text);
    margin: 0 1px;
    font-size: 0.7rem;
    text-decoration: underline dotted;
}

.footer-sep { color: var(--ui-text); opacity: 0.6; margin: 0 3px; }

/* Modal (in-page privacy dialog) */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 9999; }
.modal.open { display: flex; }
.modal { background: rgba(0,0,0,0.45); }
.modal-content { background: var(--bg-color); color: var(--text-color); max-width: 720px; width: calc(100% - 40px); padding: 20px; border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,0.4); position: relative; text-transform: none; }
.modal-content h2 { margin-top: 0; text-transform: none; }
.modal-content p, .modal-content li { font-size: 0.95rem; color: var(--text-color); }
.modal-content ul { margin: 8px 0 12px 18px; }
.modal-close { position: absolute; right: 10px; top: 8px; border: none; background: transparent; font-size: 1.6rem; cursor: pointer; color: var(--text-color); }

/* Dark mode adjustments for modal */
body.dark-mode .modal-content { background: #111; color: var(--ui-text); }
body.dark-mode .modal { background: rgba(0,0,0,0.6); }

/* Consent banner */
.consent-banner { position: fixed; left: 12px; right: 12px; bottom: 14px; z-index: 10000; display: none; }
.consent-banner.open { display: block; }
.consent-inner { display:flex; gap:12px; align-items:center; justify-content:space-between; background: var(--ui-bg); color: var(--ui-text); padding: 12px 14px; border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,0.35); }
.consent-text { font-size: 0.95rem; flex:1; }
.consent-actions { display:flex; gap:8px; align-items:center; }
.btn { background: var(--ui-text); color: var(--ui-bg); border: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; font-weight:700; }
.btn-muted { background: transparent; color: var(--ui-text); border: 1px solid rgba(140, 137, 137, 0.08); }
@media (max-width:600px) { .consent-inner { flex-direction: column; align-items:flex-start; } .consent-actions { width:100%; justify-content:flex-end; } }

/* Mobile-friendly adjustments */
@media (max-width:800px) {
    :root { --box-width: 86vw; }
    .container { width: 90vw; padding: 0 50px; box-sizing: border-box; }
    .market-track { animation-duration: 50s; }
}

@media (max-width:480px) {
    .container { width: 92vw; padding: 0 10px; box-sizing: border-box; }
    /* Stack bottom areas vertically on small screens */
    .bottom-area { display: flex; flex-direction: column; gap: 8px; overflow: auto; }
    #market-cards-container, #local-news-area, #hot-news-area, .news-container { white-space: normal; }
    #local-marquee, #hot-marquee, #news-marquee, .market-track { animation-play-state: paused; }
    /* Make toolbox touch-friendly */
    #toolbox { right: 12px; left: 12px; width: calc(100% - 24px); top: 8px; }
    .utility-btn { top: 12px; left: 12px; }
    .hamburger { top: 12px; right: 12px; }
    #close-btn { padding: 14px; }
}

/* Ad slot styling */
.ad-slot {
    width: 100%;
    max-width: 760px;
    margin: 12px auto;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.04);
    border: 1px dashed rgba(0,0,0,0.08);
    color: var(--text-color);
    font-size: 0.9rem;
    text-align: center;
}

/* Hide ad slot when aria-hidden is true or empty */
.ad-slot[aria-hidden="true"] { display: none; }

@media (max-width:480px) {
    .ad-slot { min-height: 60px; padding: 8px; }
}