/****
 * Updated style.css - Milliseconds now perfectly aligned with clock digits
 * + Mini-stopwatch with milliseconds and microseconds
 ****/

html {
    height: 100%;
}

* {
    margin: 0;
    padding: 0;
}

body {
    height: 100vh;
    display: flex;
    text-align: center;
    justify-content: center;
    align-items: center;
    background: #222;
    font-family: "Helvetica Neue", Helvetica, sans-serif;
    overflow-x: hidden;
    transition: background-color 0.05s ease;
}

.clock-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100vw;
    padding: 0 10px;
}

.clock {
    width: auto;
    display: inline-block;
}

.flip-clock-dot {
    background: #ccc;
}

.flip-clock-meridium a {
    color: #ccc;
}

h1#dateDisplay {
    font-family: "Microsoft YaHei";
    color: #ccc;
    text-align: center;
    zoom: 2;
    margin-top: 10px;
}

#box {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
}

#content {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* Milliseconds Container */
.milliseconds-container {
    display: inline-flex;
    margin-left: 10px;
    align-items: center;
    top: -10px; 
}

.milliseconds-digit {
    display: inline-block;
    font-family: "Helvetica Neue", Helvetica, sans-serif;
    font-weight: bold;
    color: #ccc;
    text-shadow: 0 1px 2px #000;
    text-align: center;
    background-color: #333;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.7);
    /* Center text vertically */
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 90px;
}

/* Stopwatch Controls Box */
.stopwatch-controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    margin-top: 25px;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border-radius: 80px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    flex-wrap: wrap;
}

.stopwatch-btn {
    padding: 18px 36px;
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    border: none;
    border-radius: 60px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 160px;
    justify-content: center;
    letter-spacing: 1px;
}

.stopwatch-btn i {
    font-size: 1.4rem;
}

.start-btn {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    color: white;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.4);
}

.start-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #3c8c40, #2e7d32);
    box-shadow: 0 6px 18px rgba(46, 125, 50, 0.5);
}

.pause-btn {
    background: linear-gradient(135deg, #e65100, #bf360c);
    color: white;
    box-shadow: 0 4px 12px rgba(230, 81, 0, 0.4);
}

.pause-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #ff6d00, #e65100);
    box-shadow: 0 6px 18px rgba(230, 81, 0, 0.5);
}

.reset-btn {
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    color: white;
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.4);
}

.reset-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #1e88e5, #1565c0);
    box-shadow: 0 6px 18px rgba(21, 101, 192, 0.5);
}

.copy-btn {
    background: linear-gradient(135deg, #6a1b9a, #4a148c);
    color: white;
    box-shadow: 0 4px 12px rgba(106, 27, 154, 0.4);
}

.copy-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #7b1fa2, #6a1b9a);
    box-shadow: 0 6px 18px rgba(106, 27, 154, 0.5);
}

.copy-btn.copied {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
}

.copy-btn i {
    margin-right: 5px;
}

.stopwatch-btn:active {
    transform: scale(0.97);
}

/* Copy feedback melding for Ctrl+C */
.copy-feedback {
    position: fixed;
    bottom: 30%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #0f0;
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 16px;
    font-family: 'Microsoft YaHei', sans-serif;
    z-index: 10001;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid #0f0;
    white-space: nowrap;
    display: none;
    text-align: center;
    font-weight: bold;
    letter-spacing: 1px;
}
/* ========== TOOLTIP FOR ALLE KNAPPER ========== */
/* Generell tooltip stil */
[title] {
    position: relative;
}

[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #0f0;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-family: 'Microsoft YaHei', sans-serif;
    white-space: nowrap;
    z-index: 10001;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    border: 1px solid #0f0;
    pointer-events: none;
    letter-spacing: 0.5px;
}

/* Tooltip for knapper nederst på skjermen (controls) - vises over */
#controls button[title]:hover::after {
    bottom: auto;
    top: -40px;
}

/* Tooltip for stopwatch kontrollene */
.stopwatch-btn[title]:hover::after {
    bottom: -40px;
    font-size: 12px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    border-color: #666;
}

/* Spesifikke farger for forskjellige knapper */
.start-btn[title]:hover::after {
    border-color: #2e7d32;
    color: #4caf50;
}

.pause-btn[title]:hover::after {
    border-color: #e65100;
    color: #ff9800;
}

.reset-btn[title]:hover::after {
    border-color: #1565c0;
    color: #42a5f5;
}

.copy-btn[title]:hover::after {
    border-color: #6a1b9a;
    color: #ce93d8;
}

/* Tooltip for mini-stopwatch knapper */
.mini-stopwatch-buttons button[title]:hover::after {
    bottom: -35px;
    font-size: 10px;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.9);
    border-color: #0f0;
    color: #0f0;
}

/* Spesifikke farger for mini-stopwatch */
.mini-start[title]:hover::after {
    border-color: #2e7d32;
    color: #4caf50;
}

.mini-pause[title]:hover::after {
    border-color: #e65100;
    color: #ff9800;
}

.mini-reset[title]:hover::after {
    border-color: #1565c0;
    color: #42a5f5;
}

.mini-copy[title]:hover::after {
    border-color: #6a1b9a;
    color: #ce93d8;
}

/* Tooltip for tastatur info */
.keyboard-info {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: #ccc;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 11px;
    font-family: 'Microsoft YaHei', sans-serif;
    z-index: 9999;
    border: 1px solid #444;
    pointer-events: none;
    backdrop-filter: blur(5px);
}

.keyboard-info:hover {
    opacity: 0.3;
}


/* Tooltip stil for alle knapper */
#controls button[title],
.stopwatch-btn[title],
.mini-stopwatch-buttons button[title] {
    position: relative;
}

#controls button[title]:hover::after,
.stopwatch-btn[title]:hover::after,
.mini-stopwatch-buttons button[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-family: 'Microsoft YaHei', sans-serif;
    white-space: nowrap;
    z-index: 10001;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

/* Tooltip for knapper nederst på skjermen (må vises over) */
#controls button[title]:hover::after {
    bottom: auto;
    top: -35px;
}

/* Tooltip for mini-stopwatch knapper */
.mini-stopwatch-buttons button[title]:hover::after {
    bottom: -35px;
    font-size: 10px;
    padding: 4px 10px;
}

/* Ekstra tooltip for space bar info */
.spacebar-info {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: #ccc;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 11px;
    font-family: 'Microsoft YaHei', sans-serif;
    z-index: 9999;
    border: 1px solid #444;
    pointer-events: none;
}

/* Kontrollknapper */
#controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    z-index: 1000;
}

#controls .signature {
    color: #888;
    font-family: "Microsoft YaHei", sans-serif;
    font-size: 12px;
    margin-left: 10px;
    white-space: nowrap;
    opacity: 0.8;
}

#controls button {
    position: relative;
    padding: 12px;
    background: linear-gradient(135deg, #555, #333);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

#controls button:hover {
    background: linear-gradient(135deg, #777, #444);
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.7);
}

#controls button:active {
    transform: scale(0.95);
}

#controls.hidden {
    display: none;
}

.clock {
    background: transparent !important;
}

/* Button Icons */
button[title="Fullskjerm"]::before { content: "\f065"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
button[title="Skjul dato"]::before { content: "\f073"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
button[title="12/24 Hour"]::before { content: "\f017"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
button[title="Clock/Stopwatch"]::before { content: "\f2f2"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
button[title="Set Alarm"]::before { content: "\f0f3"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
button[title="Start"]::before { content: "\f04b"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
button[title="Start"].active::before { content: "\f04c"; }
button[title="Reset"]::before { content: "\f2ea"; font-family: "Font Awesome 6 Free"; font-weight: 900; }

/* Fallback icons */
button[title="Fullskjerm"]::before { content: "⛶"; }
button[title="Skjul dato"]::before { content: "📅"; }
button[title="12/24 Hour"]::before { content: "🕒"; }
button[title="Clock/Stopwatch"]::before { content: "⏱"; }
button[title="Set Alarm"]::before { content: "⏰"; }
button[title="Start"]::before { content: "▶"; }
button[title="Start"].active::before { content: "⏸"; }
button[title="Reset"]::before { content: "↺"; }

/* Mode hiding */
.stopwatch-mode button[title="Set Alarm"] { display: none; }
.alarm-mode button[title="Clock/Stopwatch"] { display: none; }

/* ========== MINI-STOPWATCH MED MS OG µS ========== */
.mini-stopwatch {
    position: fixed;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 10000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 255, 0, 0.3);
    cursor: default;
    min-width: 380px;
    font-family: 'Courier New', monospace;
    transition: opacity 0.2s ease;
}

.mini-stopwatch.dragging {
    opacity: 0.8;
    cursor: grabbing;
}

.mini-stopwatch-display {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: bold;
    background: #000;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid #0f0;
    letter-spacing: 2px;
    text-align: center;
}

.mini-stopwatch-display .mini-hours,
.mini-stopwatch-display .mini-minutes,
.mini-stopwatch-display .mini-seconds {
    color: #0f0;
    text-shadow: 0 0 5px #0f0;
}

.mini-milliseconds {
    color: #ffaa00;
    text-shadow: 0 0 3px #ffaa00;
    font-size: 1.1rem;
}

.mini-microseconds {
    color: #ff6600;
    text-shadow: 0 0 3px #ff6600;
    font-size: 0.85rem;
}

.mini-stopwatch-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.mini-stopwatch-buttons button {
    background: linear-gradient(135deg, #444, #222);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    color: white;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-stopwatch-buttons button:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #666, #444);
}

.mini-drag-handle {
    position: absolute;
    top: 5px;
    right: 12px;
    cursor: grab;
    color: #0f0;
    font-size: 12px;
    letter-spacing: 2px;
    user-select: none;
    opacity: 0.6;
}

.mini-drag-handle:hover {
    opacity: 1;
}

.mini-drag-handle:active {
    cursor: grabbing;
}

.mini-stopwatch-buttons .mini-start { 
    background: linear-gradient(135deg, #2e7d32, #1b5e20); 
}
.mini-stopwatch-buttons .mini-pause { 
    background: linear-gradient(135deg, #e65100, #bf360c); 
}
.mini-stopwatch-buttons .mini-reset { 
    background: linear-gradient(135deg, #1565c0, #0d47a1); 
}
.mini-stopwatch-buttons .mini-copy { 
    background: linear-gradient(135deg, #6a1b9a, #4a148c); 
}
.mini-stopwatch-buttons .mini-copy.copied {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
}




/* ========== AUTO-SCALE BREAKPOINTS ========== */
@media (min-width: 1400px) {
    .clock { zoom: 3; }
    .milliseconds-digit { width: 60px; height: 90px; font-size: 70px; }
    .milliseconds-container { gap: 5px; margin-left: 10px; }
    .flip-clock-wrapper ul { width: 60px; height: 90px; font-size: 80px; line-height: 87px; margin: 5px; }
}

@media (max-width: 1399px) and (min-width: 1200px) {
    .clock { zoom: 2.6; }
    .milliseconds-digit { width: 52px; height: 78px; font-size: 60px; }
    .milliseconds-container { gap: 4px; margin-left: 8px; }
    .flip-clock-wrapper ul { width: 52px; height: 78px; font-size: 70px; line-height: 75px; margin: 4px; }
}

@media (max-width: 1199px) and (min-width: 1000px) {
    .clock { zoom: 2.2; }
    .milliseconds-digit { width: 44px; height: 66px; font-size: 50px; }
    .milliseconds-container { gap: 4px; margin-left: 8px; }
    .flip-clock-wrapper ul { width: 44px; height: 66px; font-size: 60px; line-height: 64px; margin: 4px; }
}

@media (max-width: 999px) and (min-width: 800px) {
    .clock { zoom: 1.8; }
    .milliseconds-digit { width: 36px; height: 54px; font-size: 42px; }
    .milliseconds-container { gap: 3px; margin-left: 6px; }
    .flip-clock-wrapper ul { width: 36px; height: 54px; font-size: 48px; line-height: 52px; margin: 3px; }
}

@media (max-width: 799px) and (min-width: 650px) {
    .clock { zoom: 1.5; }
    .milliseconds-digit { width: 30px; height: 45px; font-size: 35px; }
    .milliseconds-container { gap: 3px; margin-left: 5px; }
    .flip-clock-wrapper ul { width: 30px; height: 45px; font-size: 40px; line-height: 43px; margin: 3px; }
}

@media (max-width: 649px) and (min-width: 550px) {
    .clock { zoom: 1.3; }
    .milliseconds-digit { width: 26px; height: 39px; font-size: 30px; }
    .milliseconds-container { gap: 3px; margin-left: 5px; }
    .flip-clock-wrapper ul { width: 26px; height: 39px; font-size: 35px; line-height: 37px; margin: 2px; }
}

@media (max-width: 549px) and (min-width: 450px) {
    .clock { zoom: 1.1; }
    .milliseconds-digit { width: 22px; height: 33px; font-size: 26px; }
    .milliseconds-container { gap: 2px; margin-left: 4px; }
    .flip-clock-wrapper ul { width: 22px; height: 33px; font-size: 30px; line-height: 31px; margin: 2px; }
}

@media (max-width: 449px) {
    .clock { zoom: 0.9; }
    .milliseconds-digit { width: 18px; height: 27px; font-size: 22px; }
    .milliseconds-container { gap: 2px; margin-left: 3px; }
    .flip-clock-wrapper ul { width: 18px; height: 27px; font-size: 24px; line-height: 25px; margin: 1px; }
    .flip-clock-divider { width: 12px; }
    .flip-clock-dot { width: 6px; height: 6px; left: 3px; }
}

/* Responsiv mini-stopwatch */
@media (max-width: 768px) {
    .mini-stopwatch {
        padding: 8px 12px;
        min-width: 320px;
    }
    .mini-stopwatch-display {
        font-size: 1.1rem;
        padding: 6px 10px;
    }
    .mini-milliseconds {
        font-size: 0.9rem;
    }
    .mini-microseconds {
        font-size: 0.7rem;
    }
    .mini-stopwatch-buttons button {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .mini-stopwatch {
        min-width: 280px;
        padding: 6px 10px;
    }
    .mini-stopwatch-display {
        font-size: 0.85rem;
        padding: 4px 8px;
    }
    .mini-milliseconds {
        font-size: 0.7rem;
    }
    .mini-microseconds {
        font-size: 0.55rem;
    }
    .mini-stopwatch-buttons {
        gap: 6px;
    }
    .mini-stopwatch-buttons button {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
}

/* Responsive stopwatch controls */
@media (max-width: 768px) {
    #controls {
        flex-direction: column;
        gap: 8px;
        padding: 15px;
        border-radius: 15px;
    }
    
    #controls button {
        width: 60px;
        height: 60px;
        font-size: 22px;
    }
    
    #controls .signature {
        margin-left: 0;
        margin-top: 10px;
        order: 3;
        font-size: 10px;
    }
    
    #controls.hidden {
        display: none;
    }
    
    h1#dateDisplay {
        font-size: 10px;
        zoom: 1;
        margin-top: 8px;
    }
    
    .stopwatch-controls {
        gap: 12px;
        padding: 10px 18px;
        flex-wrap: wrap;
        border-radius: 40px;
    }
    
    .stopwatch-btn {
        padding: 12px 20px;
        font-size: 1.1rem;
        min-width: 100px;
    }
    
    .stopwatch-btn i {
        font-size: 1rem;
    }
}

@media (max-width: 550px) {
    .stopwatch-controls {
        gap: 8px;
        padding: 8px 12px;
    }
    
    .stopwatch-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
        min-width: 80px;
    }
}

/* Fix flip clock layout to stay inline */
.flip-clock-wrapper {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
}

.flip-clock-wrapper ul {
    float: none;
    display: inline-block;
}

.flip-clock-divider {
    float: none;
    display: inline-block;
}

/* Alarm blinking smooth transition */
body {
    transition: background-color 0.08s ease;
}