/* =============================================================================
   THƯỚC LỖ BAN - Premium Design System
   Synced with Tính Chuẩn Brand (tiengvietkhongdau)
   Version: 2.0.0
   ============================================================================= */

/* =========================================================================
   1. CSS RESET & BASE
   ========================================================================= */
:root {
    /* Light Mode (Default) */
    --bg-page: #f5f5f7;
    --bg-card: #ffffff;
    --bg-input: #f5f5f7;
    --text-primary: #1d1d1f;
    --text-secondary: #4b5563;
    --text-tertiary: #5a5f73;
    --accent: #1d1d1f;
    --accent-hover: #000000;
    --border: #e5e5e5;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --link-hover-bg: #f9f9fb;

    /* Ruler Colors */
    --ruler-accent: #ff6600;
    --ruler-line: orange;
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg-page: #1d1d1f;
    --bg-card: #2c2c2e;
    --bg-input: #1c1c1e;
    --text-primary: #f5f5f7;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --accent: #ffffff;
    --accent-hover: #e5e5e5;
    --border: #3a3a3c;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --link-hover-bg: #3a3a3c;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display',
        'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* =========================================================================
   2. ANIMATIONS
   ========================================================================= */
@keyframes fadeIn {
    0% {
        opacity: 0.01;
        transform: translateY(20px);
    }

    1% {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce-btn {

    0%,
    100% {
        transform: translateY(0);
    }

    25% {
        transform: translateY(-4px);
    }

    50% {
        transform: translateY(0);
    }

    75% {
        transform: translateY(-2px);
    }
}

/* =========================================================================
   3. LAYOUT - Container
   ========================================================================= */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================================================
   4. NAVIGATION ROW
   ========================================================================= */
.nav-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: 980px;
    box-shadow: 0 2px 8px var(--shadow);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.back-link:hover {
    background: var(--accent);
    color: var(--bg-card);
}

/* Bookmark Button */
.bookmark-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--bg-card);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 16px;
    background: var(--accent);
    border: none;
    border-radius: 980px;
    box-shadow: 0 2px 8px var(--shadow-hover);
    text-decoration: none;
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    animation: bounce-btn 2s ease-in-out infinite;
}

.bookmark-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow-hover);
    animation: none;
}

.bookmark-btn:active {
    cursor: grabbing;
    transform: scale(0.98);
}

/* Custom Tooltip */
.bookmark-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 50%;
    right: calc(100% + 10px);
    transform: translateY(-50%) translateX(5px);
    background: #ffffff;
    color: #1d1d1f;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.bookmark-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    right: calc(100% + 5px);
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left-color: #ffffff;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
}

.bookmark-btn:hover::after,
.bookmark-btn:hover::before {
    opacity: 1;
    visibility: visible;
}

.bookmark-btn:hover::after {
    transform: translateY(-50%) translateX(0);
}

/* Hide on tablet and mobile */
@media (max-width: 900px) {
    .bookmark-btn {
        display: none;
    }
}

/* Theme Toggle Button */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    margin-left: 12px;
    border: none;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 2px 8px var(--shadow);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Light mode default: show moon icon (click to go dark) */
.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

/* Dark mode: show sun icon (click to go light) */
[data-theme="dark"] .sun-icon {
    display: block;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

/* =========================================================================
   5. TOOL HEADER
   ========================================================================= */
.tool-header {
    text-align: center;
    margin-bottom: 32px;
}

.tool-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.tool-header .subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
}

/* =========================================================================
   6. RULER TOOL SECTION (Full Width)
   ========================================================================= */
.ruler-section {
    background: var(--bg-card);
    border-radius: 0;
    box-shadow: 0 1px 3px var(--shadow);
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    width: 100vw;
    margin-bottom: 24px;
    overflow: hidden;
}

.ruler-container {
    position: relative;
    padding-top: 60px;
    width: 100%;
    overflow: hidden;
}

/* Ruler Outer Container */
#lobanOuter {
    width: 100%;
    position: relative;
    height: 400px;
    padding: 0 20px;
}

/* Hidden Debug Element */
#abc {
    position: absolute;
    top: -20px;
    display: none;
}

/* Touch Areas for Mobile */
.loban-touch-left,
.loban-touch-right {
    position: absolute;
    top: 31px;
    height: 358px;
    width: 50px;
    z-index: 2;
}

.loban-touch-left {
    left: 0;
}

.loban-touch-right {
    right: 0;
}

/* Measurement Display */
#sodoLoban {
    display: none;
    position: absolute;
    z-index: 2;
    top: 5px;
    left: 400px;
    text-align: center;
    width: 100px;
    font-size: 16px;
    font-weight: 700;
    color: #e54545;
}

/* Input Container */
#container-sodo {
    position: absolute;
    z-index: 100;
    top: -48px;
    display: flex;
    justify-content: center;
    left: 0;
    right: 0;
    pointer-events: auto;
}

/* Measurement Input */
#sodo {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: #e54545;
    border: 2px solid var(--ruler-line);
    padding: 2px;
    height: 50px;
    width: 100px;
    border-radius: 8px;
    outline: none;
    cursor: text;
    background: var(--bg-card);
    position: relative;
    pointer-events: auto;
    transition: all 0.2s ease;
}

#sodo:hover {
    border-color: var(--ruler-accent);
    background: var(--bg-input);
}

#sodo:focus {
    border-color: var(--ruler-accent);
    box-shadow: 0 0 0 3px rgba(255, 102, 0, 0.2);
    background: var(--bg-card);
}

/* Input Label */
.enter-number {
    position: absolute;
    top: -35px;
    right: 0;
    left: 202px;
    display: flex;
    justify-content: center;
    z-index: 10;
    font-size: 14px;
    color: var(--text-tertiary);
}

/* Measurement Line */
#thanhdo {
    width: 2px;
    height: 384px;
    background: var(--ruler-line);
    position: absolute;
    z-index: 2;
    top: 10px;
    left: 240px;
}

/* Help Note */
.loban-note {
    position: absolute;
    z-index: 2;
    top: 0;
    right: 20px;
    padding-left: 0;
    height: 20px;
    margin: 0;
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Ruler Type Labels */
.loban-t {
    position: absolute;
    z-index: 2;
    left: 28px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.loban-t strong {
    color: var(--text-primary);
}

.loban-522 {
    top: 7px;
}

.loban-429 {
    top: 143px;
}

.loban-388 {
    top: 280px;
}

/* Ruler Wrapper */
#loban-wrapper {
    position: absolute;
    z-index: 1;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 412px;
    background: var(--bg-card);
    overflow: hidden;
}

/* Ruler Scroller */
#loban-scroller {
    width: 500000px;
    /* 50 segments * 10000px each */
    height: 100%;
    float: left;
    padding: 0;
    transition-property: transform;
    transform-origin: 0 0 0;
    transition-timing-function: cubic-bezier(.33, .66, .66, 1);
    transform: translate(0, 0) translateZ(0);
}

/* Ruler List */
#loban-thelist {
    padding: 0;
    margin: 0;
    list-style: none;
}

#loban-scroller li {
    display: block;
    float: left;
    width: 10000px;
    height: 100%;
}

#loban-scroller li img {
    margin-top: 30px;
    max-width: none;
}

/* Pull Indicators */
#pullLeft,
#pullRight {
    display: block;
    width: 50px;
    float: left;
    height: 100%;
}

/* Clearfix */
.loban-clear:after,
.loban-clear:before {
    content: ' ';
    display: table;
}

.loban-clear:after {
    clear: both;
}

/* Unit Display */
.loban-dvt {
    text-align: right;
    padding: 15px 20px;
    font-size: 13px;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border);
}

/* =========================================================================
   7. CONTENT LAYOUT
   ========================================================================= */
.content-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    margin-bottom: 24px;
}

/* =========================================================================
   8. INFO ARTICLE
   ========================================================================= */
.info-article {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 1px 3px var(--shadow);
}

.info-article .intro {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.info-article h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 28px;
    margin-bottom: 16px;
}

.info-article h2:first-of-type {
    margin-top: 0;
}

.info-article h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 20px;
    margin-bottom: 12px;
}

.info-article p {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.info-article ol,
.info-article ul {
    margin-left: 20px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.info-article li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.info-article strong {
    color: var(--text-primary);
}

/* =========================================================================
   9. SIDEBAR
   ========================================================================= */
.sidebar {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.sidebar-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px var(--shadow);
}

.sidebar-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.sidebar-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-links li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.sidebar-links li a:hover {
    background: var(--link-hover-bg);
    box-shadow: 0 2px 8px var(--shadow);
}

/* =========================================================================
   10. FOOTER
   ========================================================================= */
footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer a {
    color: var(--text-primary);
    text-decoration: none;
}

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

.footer-link {
    color: var(--text-primary);
}

/* =========================================================================
   11. RESPONSIVE DESIGN
   ========================================================================= */
@media (max-width: 900px) {
    .content-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .tool-header h1 {
        font-size: 1.5rem;
    }

    .loban-t {
        font-size: 12px !important;
    }

    .loban-522 {
        margin: 0;
        top: 12px;
    }

    .loban-429 {
        top: 148px;
    }

    .loban-note {
        display: none;
    }

    .loban-388 {
        top: 284px;
    }

    .enter-number {
        font-size: 12px;
        left: 170px;
    }

    #sodo {
        width: 80px;
        height: 40px;
        font-size: 16px;
    }

    #container-sodo {
        top: -42px;
    }

    .info-article {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px 15px;
    }

    .tool-header h1 {
        font-size: 1.3rem;
    }

    .tool-header .subtitle {
        font-size: 0.9rem;
    }
}

/* =========================================================================
   12. FAQ SECTION (Toggle)
   ========================================================================= */
.faq-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.faq-item {
    background: var(--bg-input);
    border-radius: 10px;
    padding: 0;
    border: 1px solid var(--border);
    overflow: hidden;
}

.faq-item summary {
    padding: 16px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s ease;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
    content: '−';
}

.faq-item summary:hover {
    background: var(--border);
}

.faq-item p {
    padding: 12px 16px 16px;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    padding-top: 4px;
}

/* =========================================================================
   13. FOCUS STATES (Accessibility)
   ========================================================================= */
button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}