/* ========================================
   InchRuler.com - Full-Screen Ruler Design
   Ruler-First, Minimal UI
   ======================================== */

:root {
    --primary: #FFD700;
    --dark: #1a1a1a;
    --darker: #0d0d0d;
    --ruler-yellow: #FFE87C;
    --ruler-cream: #FFF8DC;
    --text-light: #ccc;
    --border: #333;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--dark);
    color: #fff;
    overflow-x: hidden;
}

/* ========================================
   Compact Header
   ======================================== */
.compact-header {
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    user-select: none;
}

.quick-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Quick Calibration Dropdown */
.quick-select {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    max-width: 200px;
}

.quick-select:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
}

.quick-select:focus {
    border-color: var(--primary);
}

.quick-select option, .quick-select optgroup {
    background: #222;
    color: #fff;
}

/* Compact Unit Toggle */
.unit-toggle-compact {
    display: flex;
    align-items: center;
    gap: 6px;
}

.switch-compact {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch-compact input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-compact {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
    border-radius: 22px;
}

.slider-compact::before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider-compact {
    background-color: var(--primary);
}

input:checked + .slider-compact::before {
    transform: translateX(18px);
}

.unit-label-compact {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    min-width: 25px;
}

/* Compact Buttons */
.btn-compact {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-compact:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-compact:active {
    transform: translateY(0);
}

/* ========================================
   Full-Screen Ruler Viewport
   ======================================== */
.ruler-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.ruler-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2a2a2a 0%, var(--dark) 100%);
    padding: 20px;
    min-height: calc(100vh - 120px);
}

.ruler-container {
    background: linear-gradient(to bottom, var(--ruler-yellow) 0%, var(--ruler-cream) 100%);
    border: 3px solid #333;
    border-radius: 12px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 215, 0, 0.1);
    width: 100%;
    max-width: 100%;
    position: relative;
    padding: 30px 20px;
    min-height: 200px;
}

.ruler-svg {
    display: block;
    width: 100%;
}

/* ========================================
   Measurement Line
   ======================================== */
.measurement-line {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    background: #e74c3c;
    cursor: ew-resize;
    z-index: 10;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.6);
}

.line-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 50px;
    background: #e74c3c;
    border-radius: 6px;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.line-handle:active {
    cursor: grabbing;
}

.measurement-value {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ========================================
   Status Bar
   ======================================== */
.status-bar {
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    border-top: 1px solid var(--border);
}

/* ========================================
   Content Below the Fold
   ======================================== */
.content-below {
    background: #0d0d0d;
    padding: 60px 20px;
    color: #ccc;
}

.content-wrapper {
    max-width: 800px;
    margin: 0 auto;
}

.content-below h1 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 20px;
}

.content-below h2 {
    font-size: 1.5rem;
    color: #fff;
    margin-top: 40px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
}

.content-below p {
    margin-bottom: 15px;
    line-height: 1.7;
}

.content-below ul, .content-below ol {
    margin: 15px 0 20px 30px;
    line-height: 1.8;
}

.content-below li {
    margin-bottom: 10px;
}

.footer-links {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
    text-align: center;
}

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

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

/* ========================================
   Modal
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Calibration Tabs */
.calibration-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #ccc;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #000;
}

.calibration-method {
    display: none;
}

.calibration-method.active {
    display: block;
}

.method-desc {
    margin-bottom: 20px;
    color: #ccc;
}

/* Diagonal Input */
.diagonal-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
}

.diagonal-input-group input[type="number"] {
    flex: 1;
    padding: 12px;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #fff;
    outline: none;
}

.diagonal-input-group input[type="number"]:focus {
    border-color: var(--primary);
}

.input-suffix {
    color: #999;
    font-size: 14px;
}

.detected-info {
    background: rgba(52, 152, 219, 0.1);
    border-left: 3px solid #3498db;
    padding: 15px;
    border-radius: 4px;
    margin-top: 20px;
    font-size: 14px;
    color: #ccc;
}

.detected-info strong {
    color: #fff;
}

.detected-info span {
    color: var(--primary);
    font-weight: 700;
}

/* Credit Card Visual */
.calibration-visual {
    background: linear-gradient(to bottom, var(--ruler-yellow) 0%, var(--ruler-cream) 100%);
    border: 2px solid #333;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.calibration-control {
    margin: 30px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.calibration-control input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
}

.calibration-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.calibration-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.ppi-display {
    text-align: center;
    font-size: 18px;
    color: #fff;
}

.ppi-display strong {
    color: var(--primary);
    font-size: 24px;
}

.calibration-hint {
    background: rgba(255, 193, 7, 0.1);
    border-left: 3px solid #ffc107;
    padding: 12px;
    border-radius: 4px;
    margin-top: 15px;
    font-size: 13px;
    color: #ccc;
}

.current-ppi-display {
    text-align: center;
    margin-top: 25px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 14px;
    color: #ccc;
}

.current-ppi-display strong {
    color: var(--primary);
    font-size: 20px;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: #000;
}

.btn-primary:hover {
    background: #FFC700;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .compact-header {
        padding: 8px 15px;
    }

    .logo {
        font-size: 16px;
    }

    .quick-select {
        max-width: 150px;
        font-size: 12px;
    }

    .quick-controls {
        gap: 8px;
    }

    .ruler-viewport {
        padding: 15px;
        min-height: calc(100vh - 100px);
    }

    .ruler-container {
        padding: 20px 15px;
    }

    .content-below {
        padding: 40px 20px;
    }

    .content-below h1 {
        font-size: 1.5rem;
    }

    .content-below h2 {
        font-size: 1.25rem;
    }

    .modal-content {
        width: 95%;
    }

    .modal-header, .modal-body, .modal-footer {
        padding: 20px;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .compact-header,
    .quick-controls,
    .status-bar,
    .content-below {
        display: none !important;
    }

    body {
        background: white;
    }

    .ruler-container {
        box-shadow: none;
        border: 2px solid black;
    }
}

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

button:focus, a:focus, input:focus, select:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
