/* cam-c-vision/style.css */

:root {
    --primary-color: #ff3b30;
    --bg-color: #000000;
    --panel-bg: rgba(28, 28, 30, 0.85); /* Dark translucent */
    --text-color: #ffffff;
    --active-color: #ffd60a;
    --border-color: #38383a;
    --shutter-size: 64px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Noto Sans JP', sans-serif;
}

#appContainer {
    display: flex;
    flex-direction: column;
    height: 100vh; /* 100vh ensures the camera app part takes exactly one screen */
    width: 100%;
}

/* --- Camera View Area --- */
#cameraView {
    flex: 1;
    position: relative;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#canvasElement {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#loadingOverlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
    text-align: center;
}

#loadingOverlay p {
    font-size: 16px;
    margin-bottom: 24px;
}

/* Rest of the UI overlays */
.privacy-notice {
    position: absolute;
    top: calc(env(safe-area-inset-top, 20px) + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: rgba(255,255,255,0.9);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}

.status-badge {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--active-color);
    color: #000;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
}

.status-badge.hidden {
    display: none;
}

/* --- Capture / Pause Overlay --- */
#capturePanel {
    position: absolute;
    top: 70px;
    left: 0; right: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 40;
    pointer-events: none;
}
#capturePanel.hidden {
    display: none;
}

#capturePanel .action-btn {
    pointer-events: auto;
}

/* --- Buttons --- */
.action-btn {
    background: #ffffff;
    color: #000000;
    border: none;
    border-radius: 30px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.action-btn.primary {
    background: var(--primary-color);
    color: #fff;
}
.action-btn.cancel {
    background: rgba(255,255,255,0.2);
    color: #fff;
    backdrop-filter: blur(10px);
}
.action-btn:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* --- Control Panel --- */
#controlPanel {
    background-color: var(--panel-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 20px);
    touch-action: none;
    z-index: 100;
}

/* --- Mode Selector --- */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 25px;
    padding: 12px 0 0 0;
}
.mode-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}
.mode-btn.active {
    color: var(--active-color);
}

/* Filter Selector Ribbon */
.filter-selector-wrapper {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.filter-selector-wrapper::-webkit-scrollbar {
    display: none;
}
.filter-selector {
    display: flex;
    padding: 15px 20px;
    gap: 15px;
    width: max-content;
    margin: 0 auto;
}
.filter-btn {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}
.filter-btn span {
    font-size: 10px;
    font-weight: normal;
    opacity: 0.8;
}
.filter-btn.active {
    color: var(--active-color);
}
.filter-btn.active::after {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background-color: var(--active-color);
    border-radius: 50%;
    margin-top: 2px;
}

/* Controls Row */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px 20px;
    width: 100%;
}
.controls-left, .controls-right {
    display: flex;
    flex: 1; /* Center spacer takes remaining space symmetrically */
    align-items: center;
}
.controls-left {
    justify-content: center;
}
.controls-center {
    display: flex;
    justify-content: center;
    flex: 0 0 auto;
}
.controls-right {
    justify-content: center;
    gap: 15px;
}
.nav-btn-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 60px;
}
.nav-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}
.nav-btn:active, .nav-btn:hover {
    background: rgba(255,255,255,0.3);
}
.nav-btn.active {
    background: rgba(255, 59, 48, 0.2); /* Faint red background when ON */
    color: #ff3b30;
}
.mic-icon.hidden {
    display: none;
}
.nav-label {
    font-size: 11px;
    color: #999;
    text-decoration: none;
    white-space: nowrap;
}

/* --- Footer Links --- */
.footer-links {
    text-align: center;
    padding: 10px 0 5px 0;
}
.footer-links a {
    color: #aaa;
    font-size: 11px;
    text-decoration: underline;
    margin: 0 5px;
}
.footer-links .divider {
    color: #555;
    font-size: 11px;
    margin: 0 5px;
}

/* Shutter Button */
.shutter-btn {
    width: var(--shutter-size);
    height: var(--shutter-size);
    border-radius: 50%;
    background-color: transparent;
    border: 4px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.shutter-inner {
    width: calc(var(--shutter-size) - 14px);
    height: calc(var(--shutter-size) - 14px);
    border-radius: 50%;
    background-color: #fff;
    transition: all 0.2s ease;
}
.shutter-btn:active .shutter-inner {
    transform: scale(0.9);
    background-color: #e0e0e0;
}
.shutter-btn.paused {
    border-color: var(--primary-color);
}
.shutter-btn.paused .shutter-inner {
    background-color: var(--primary-color);
    border-radius: 8px;
    transform: scale(0.6);
}

/* Recording / Video mode shutter button */
.shutter-btn.video-mode {
    border-color: #ff3b30;
}
.shutter-btn.video-mode .shutter-inner {
    background-color: #ff3b30;
}
.shutter-btn.recording {
    border-color: #ff3b30;
}
.shutter-btn.recording .shutter-inner {
    background-color: #ff3b30;
    border-radius: 8px;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Recording indicator */
.record-badge {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(4px);
}
.record-badge.hidden {
    display: none;
}
.red-dot {
    width: 10px;
    height: 10px;
    background-color: #ff3b30;
    border-radius: 50%;
    animation: blink 1s infinite alternate;
}
@keyframes blink {
    from { opacity: 1; }
    to { opacity: 0.3; }
}

/* --- Zoom Slider UI --- */
.zoom-container {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    background: rgba(28, 28, 30, 0.7);
    padding: 8px 16px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 50;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: opacity 0.3s;
}
.zoom-container.hidden {
    display: none;
}
.zoom-label {
    font-size: 13px;
    font-weight: bold;
    color: #fff;
    min-width: 38px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
#zoomSlider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: 4px;
    border-radius: 2px;
}
#zoomSlider::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}
#zoomSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    margin-top: -7px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}
#zoomSlider:active::-webkit-slider-thumb {
    transform: scale(1.2);
}

/* --- SEO Text Area at the bottom --- */
.seo-text-area {
    background-color: #111;
    color: #999;
    padding: 30px 20px;
    font-size: 12px;
    line-height: 1.6;
}
.seo-text-area h1 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #bbb;
}

/* --- Save Modal --- */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-out;
}
.modal.visible {
    opacity: 1;
    pointer-events: auto;
}
.modal.hidden {
    display: none;
}
.modal-content {
    background: #1c1c1e;
    border-radius: 16px;
    padding: 30px 20px 20px;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.visible .modal-content {
    transform: translateY(0) scale(1);
}
.close-modal-btn {
    position: absolute;
    top: -16px;
    right: -10px;
    background: #444;
    border: 2px solid #1c1c1e;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    z-index: 201;
}
.modal-instruction {
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 15px;
    text-align: center;
    letter-spacing: 0.05em;
}
.modal-image-container {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    margin-bottom: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
#resultImage {
    width: 100%;
    height: auto;
    display: block;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: default; /* Enables long-press image menu on iOS Safari */
}
.modal-subtext {
    font-size: 11px;
    color: #888;
    text-align: center;
}

/* --- Responsive Layout for PC (Landscape Webcams) --- */
@media screen and (min-width: 768px) and (orientation: landscape) {
    #appContainer {
        flex-direction: row;
    }
    #controlPanel {
        width: 320px;
        flex-direction: column;
        justify-content: center;
        border-left: 1px solid var(--border-color);
        padding-bottom: 0;
    }
    .filter-selector-wrapper {
        overflow-y: auto;
        overflow-x: hidden;
        flex: 1;
        display: flex;
        align-items: center;
    }
    .filter-selector {
        flex-direction: column;
        width: 100%;
        gap: 25px;
    }
    .controls-row {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 15px;
        padding: 20px;
    }
}

/* --- Portrait orientation recommended (landscape block) UI --- */
#landscape-blocker {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
#landscape-blocker.hidden {
    display: none !important;
}
.blocker-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: rotatePhone 2s infinite ease-in-out;
}
.blocker-content svg {
    color: #ff3b30;
}
.blocker-content p {
    font-size: 16px;
    line-height: 1.6;
    letter-spacing: 0.05em;
}
.blocker-content strong {
    color: #ff3b30;
    font-size: 18px;
}
@keyframes rotatePhone {
    0% { transform: rotate(-90deg); }
    30% { transform: rotate(0deg); }
    70% { transform: rotate(0deg); }
    100% { transform: rotate(-90deg); }
}

/* Show blocker when mobile device is in landscape */
@media screen and (max-width: 899px) and (orientation: landscape) and (max-height: 600px) {
    #landscape-blocker:not(.hidden-by-js) {
        display: flex !important;
    }
}
