
:root {
    --ppcm: 37.795px; 
}

html { overflow-y: scroll; }
body { -webkit-tap-highlight-color: transparent; }

/* Utilities */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.pb-safe { padding-bottom: env(safe-area-inset-bottom); }

/* RULER BASE */
.ruler-instance {
    position: relative;
    width: 100%;
    height: 140px; 
    background-color: white;
    overflow: hidden;
    user-select: none;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    touch-action: pan-y;
    transition: background 0.3s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* === RULER THEMES === */

/* Theme 1: Yellow Wood */
.ruler-theme-wood {
    background-color: #f3e5ab; /* Cornsilk/Wood */
    background-image: linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px),
                      linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}
.ruler-theme-wood .tick-major { border-color: #5c4033; }
.ruler-theme-wood .tick-minor { border-color: #8b5a2b; }
.ruler-theme-wood .tick-label { color: #3e2723; }

/* Theme 2: Green Plastic */
.ruler-theme-plastic {
    background-color: #86efac; /* Green-300 */
    border-bottom: 2px solid #22c55e;
}
.ruler-theme-plastic .tick-major { border-color: #14532d; } /* Green-900 */
.ruler-theme-plastic .tick-minor { border-color: #15803d; } /* Green-700 */
.ruler-theme-plastic .tick-label { color: #064e3b; }

/* Theme 3: Silver Aluminum */
.ruler-theme-silver {
    background: linear-gradient(180deg, #f1f5f9 0%, #cbd5e1 50%, #94a3b8 100%);
}
.ruler-theme-silver .tick-major { border-color: #0f172a; }
.ruler-theme-silver .tick-minor { border-color: #334155; }
.ruler-theme-silver .tick-label { color: #0f172a; }

/* Theme 4: White (Default) */
.ruler-theme-white {
    background-color: #ffffff;
}
.ruler-theme-white .tick-major { border-color: #000; }
.ruler-theme-white .tick-minor { border-color: #9ca3af; }
.ruler-theme-white .tick-label { color: #000; }

/* Theme 5: Matte Sky Blue */
.ruler-theme-blue {
    background-color: #7dd3fc; /* Sky-300 */
}
.ruler-theme-blue .tick-major { border-color: #0c4a6e; }
.ruler-theme-blue .tick-minor { border-color: #0284c7; }
.ruler-theme-blue .tick-label { color: #082f49; }


/* TICKS */
.tick {
    position: absolute;
    bottom: 0;
    border-style: solid;
    pointer-events: none;
    left: calc(var(--ppcm) * var(--pos));
    border-left-width: 1px;
    transform: translateX(-50%);
    transition: left 0.3s, right 0.3s;
}

.tick-major { height: 45px; border-left-width: 2px; z-index: 1; }
.tick-minor { height: 18px; border-left-width: 1px; }

.tick-label {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
}

/* OPTIONS */
.ruler-reverse .tick {
    left: auto;
    right: calc(var(--ppcm) * var(--pos));
    transform: translateX(50%);
}
.ruler-thick .tick-major { border-left-width: 4px; }
.ruler-thick .tick-minor { border-left-width: 2px; }
.ruler-thick .tick-label { font-size: 16px; font-weight: 900; }
.ruler-no-minor .tick-minor { display: none; }

/* MEASUREMENTS */
.marker-container { position: absolute; inset: 0; z-index: 20; cursor: crosshair; }
.measuring-dot {
    position: absolute; bottom: 20px; width: 24px; height: 24px;
    background-color: black; border: 3px solid white; border-radius: 50%;
    transform: translateX(-50%); box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    cursor: grab; z-index: 30;
}
.ruler-reverse .measuring-dot { transform: translateX(50%); left: auto !important; }
.measuring-line { position: absolute; bottom: 30px; height: 3px; background-color: black; z-index: 25; pointer-events: none; }
.measurement-badge {
    position: absolute; bottom: 35px; left: 50%; transform: translateX(-50%);
    background-color: black; color: white; font-size: 12px; font-weight: bold;
    padding: 4px 10px; border-radius: 6px; white-space: nowrap; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-family: ui-monospace, SFMono-Regular, monospace !important;
}

/* Animations */
@keyframes slide-down {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-slide-down { animation: slide-down 0.3s ease-out forwards; }

#cal-ref-obj { container-type: size; }
#cal-ref-obj .font-mono { font-family: ui-monospace, SFMono-Regular, monospace !important; }

/* Pulsating Yellow Effect */
@keyframes pulse-yellow {
    0% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(234, 179, 8, 0); }
    100% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0); }
}
.pulse-yellow-shadow {
    animation: pulse-yellow 2s infinite;
    border-color: #eab308 !important; /* Yellow-500 */
}

/* Vertical Ruler Mode */
.vertical-ruler-wrapper {
    position: fixed;
    top: 0;
    right: 0;
    width: 80px; /* Width of the vertical ruler strip */
    height: 100vh;
    background: white;
    z-index: 40;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.vertical-ruler-wrapper.left-side {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid #e5e7eb;
}

/* === NEW TOOLS === */
.tool-panel { display: none; width: 100%; height: 100%; min-height: 60vh; position: relative; }
.tool-panel.active { display: flex; flex-direction: column; align-items: center; }

/* Ring Sizer */
#ring-circle {
    width: 200px; height: 200px;
    border-radius: 50%;
    border: 2px solid #ef4444; /* Red-500 */
    background: rgba(239, 68, 68, 0.1);
    box-shadow: 0 0 0 9999px rgba(255,255,255,0.8); /* Focus mask */
    position: relative;
    z-index: 10;
    pointer-events: none; /* Let clicks pass to slider if needed */
}

/* Sewing Grid */
#sewing-grid {
    width: 100%; height: 60vh;
    background-color: #000;
    background-image: 
        linear-gradient(#22c55e 1px, transparent 1px),
        linear-gradient(90deg, #22c55e 1px, transparent 1px);
    background-size: 100px 100px; /* JS will update this */
    background-position: -1px -1px;
}

/* Thread Pitch */
.pitch-line {
    width: 100%;
    border-bottom: 2px solid #000;
    position: absolute;
    left: 0;
}
