/* ====== Design Tokens ====== */
:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #60a5fa;
    --border-color: #334155;
    --radius-lg: 12px;
    --radius-md: 8px;
    --danger: #ef4444;
    --success: #22c55e;
    --line-color: #f43f5e;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ====== Header ====== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-color), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

/* ====== Buttons ====== */
.btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 0.5rem 1.15rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
}

.btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

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

/* ====== Layout ====== */
.container {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
    max-width: 1500px;
    margin: 0 auto;
}

@media (min-width: 1050px) {
    .container {
        flex-direction: row;
        align-items: flex-start;
        padding: 2rem;
        gap: 1.5rem;
    }

    .pane {
        min-width: 0;
    }

    #source-pane {
        flex: 1;
    }

    #hough-pane {
        flex: 1.1;
    }
}

/* ====== Cards ====== */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.15),
        0 2px 4px -1px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s;
}

.card:hover {
    box-shadow:
        0 8px 16px -2px rgba(0, 0, 0, 0.25),
        0 4px 8px -2px rgba(0, 0, 0, 0.12);
}

/* ====== Typography ====== */
h2 {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

/* ====== Controls ====== */
.control-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.control-row label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

select {
    background-color: var(--border-color);
    color: var(--text-primary);
    border: 1px solid #475569;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s;
    max-width: 280px;
}

select:focus {
    border-color: var(--accent-color);
}

input[type="range"] {
    accent-color: var(--accent-color);
    cursor: pointer;
    width: 120px;
}

.range-val {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--accent-hover);
    min-width: 28px;
    text-align: center;
}

/* ====== Canvas ====== */
.canvas-pair {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.canvas-block {
    flex: 1;
    min-width: 200px;
}

.canvas-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    padding: 0;
    position: relative;
    border: 1px solid var(--border-color);
}

canvas {
    background-color: #000;
    image-rendering: auto;
    display: block;
}

#source-canvas {
    width: 256px;
    max-width: 100%;
    aspect-ratio: 1 / 1;
}

#hough-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

#hough-canvas {
    display: block;
    max-width: 100%;
    max-height: 600px;
    width: auto;
    height: auto;
}

#hough-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-color: transparent;
}

.interactable {
    cursor: crosshair;
}

/* ====== Axis Labels ====== */
.axis-labels {
    display: flex;
    gap: 0.35rem;
    align-items: stretch;
}

.axis-label-y {
    writing-mode: vertical-lr;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.15rem;
}

.hough-canvas-area {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.axis-label-x {
    text-align: center;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding-top: 0.1rem;
}

/* ====== Info Box ====== */
.info-box {
    margin-top: 1rem;
    background-color: rgba(0, 0, 0, 0.25);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.info-box h3 {
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.value-display {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--accent-hover);
    word-break: break-word;
    line-height: 1.5;
}

/* ====== Responsive ====== */
@media (max-width: 600px) {
    header {
        padding: 0.75rem 1rem;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .container {
        padding: 1rem;
        gap: 1rem;
    }

    .card {
        padding: 1rem;
    }

    .canvas-pair {
        flex-direction: column;
    }

    .canvas-block {
        min-width: unset;
    }

    select {
        max-width: 100%;
    }
}

/* ====== Animations ====== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.card {
    animation: fadeIn 0.4s ease-out both;
}

.card:nth-child(2) {
    animation-delay: 0.08s;
}
