@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;500;700&display=swap');

:root {
    --bg-color: #18181b;
    --card-bg: #27272a;
    --text-primary: #f4f4f5;
    --text-dim: #a1a1aa;
    --accent-primary: #d4d4d8;
    --accent-soft: #71717a;
    --border-color: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.05);
    --radius-lg: 28px;
    --radius-sm: 14px;
    --soft-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    --hover-shadow: rgba(255, 255, 255, 0.1);
    --corner-fill: #f4f4f5;
    --corner-color: #18181b;
    --smooth-transition: all 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

[data-theme="light"] {
    --bg-color: #f4f4f6;
    --card-bg: #ffffff;
    --text-primary: #18181b;
    --text-dim: #71717a;
    --accent-primary: #27272a;
    --accent-soft: #e4e4e7;
    --border-color: rgba(0, 0, 0, 0.09);
    --card-border: rgba(0, 0, 0, 0.06);
    --soft-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    --hover-shadow: rgba(0, 0, 0, 0.12);
    --corner-fill: #18181b;
    --corner-color: #f4f4f6;
}

.theme-toggle-corner {
    position: fixed;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border: 0;
    background: transparent;
    cursor: pointer;
    z-index: 9999;
    padding: 0;
    line-height: 0;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.theme-toggle-corner:focus,
.theme-toggle-corner:focus-visible,
.theme-toggle-corner:active {
    outline: none;
    box-shadow: none;
}

.theme-toggle-corner svg {
    width: 100%;
    height: 100%;
    fill: var(--corner-fill);
    color: var(--corner-color);
    transition: var(--smooth-transition);
}

.theme-toggle-corner:hover svg {
    transform: scale(1.06);
}

.theme-toggle-corner .icon-sun,
.theme-toggle-corner .icon-moon {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-toggle-corner .icon-sun {
    display: block;
}
.theme-toggle-corner .icon-moon {
    display: none;
}

[data-theme="light"] .theme-toggle-corner .icon-sun {
    display: none;
}
[data-theme="light"] .theme-toggle-corner .icon-moon {
    display: block;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: 'Quicksand', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.main-container {
    width: 100%;
    max-width: 1200px;
    min-height: 100vh;
    padding: 60px 24px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.title-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

h1 {
    font-weight: 700;
    font-size: 3.2rem;
    margin: 0;
    color: var(--accent-primary);
    letter-spacing: -1.5px;
    text-align: center;
}

.version-icon {
    width: 30px;
    height: auto;
    opacity: 0.3;
    filter: grayscale(1);
}

.question-container {
    min-height: 140px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

#question {
    background-color: var(--card-bg);
    padding: 35px 50px;
    border-radius: var(--radius-lg);
    font-size: 1.4rem;
    font-weight: 500;
    line-height: 1.5;
    box-shadow: var(--soft-shadow);
    max-width: 800px;
    border: 1px solid var(--card-border);
    text-align: center;
}

button {
    padding: 16px 24px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--smooth-transition);
}

button:hover {
    background-color: var(--text-primary);
    color: var(--bg-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--hover-shadow);
}

.description-box {
    background-color: var(--card-bg);
    padding: 14px 24px;
    border-radius: var(--radius-lg);
    text-align: left;
    line-height: 1.7;
    border: 1px solid var(--card-border);
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
    align-self: center;
    margin-top: 10px;
}

.license-bubble {
    background-color: var(--card-bg);
    color: var(--text-primary);
    width: 90%;
    max-width: 800px;
    height: auto;
    max-height: 60vh;
    padding: 30px;
    border-radius: var(--radius-lg);
    overflow-y: auto;
    border: 1px solid var(--card-border);
    margin-top: 20px;
    margin-bottom: 20px;
}

#buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 480px;
    margin-top: 20px;
    margin-bottom: 50px;
}

.button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 40px;
    width: 100%;
}

.button-container button {
    width: auto;
    min-width: 220px;
    max-width: 400px;
    text-align: center;
}

#buttons.multi-column {
    display: flex;
    flex-direction: column;
    max-width: 480px;
    gap: 12px;
}

.values-flex-container {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 28px 20px;
    margin-top: 20px;
    width: 100%;
    box-sizing: border-box;
}

#ideologies-container .values-flex-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 12px;
    margin-top: 15px;
}

.result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 140px;
    min-width: 0;
    box-sizing: border-box;
    transition: var(--smooth-transition);
}

.result-icon {
    width: 90px;
    height: 90px;
    margin-bottom: 10px;
    flex-shrink: 0;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3));
    transition: var(--smooth-transition);
}

.result-item:hover .result-icon {
    transform: scale(1.08);
}

.result-text {
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-dim);
    text-transform: uppercase;
    text-align: center;
    width: 100%;
    margin: 0;
    padding: 0 4px;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-break: normal;
    hyphens: auto;
}

.label-bubble {
    display: inline-block;
    padding: 14px 40px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.8rem;
    color: #ffffff;
    margin: 15px 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: var(--smooth-transition);
    box-sizing: border-box;
}

#secondary-label {
    background-color: transparent !important;
    font-size: 1.1rem;
    margin-top: 10px;
    border: 2px solid;
    box-shadow: none;
}

.category-section {
    width: 100%;
    margin-bottom: 45px;
}

.category-title {
    font-size: 1.5rem;
    color: var(--accent-primary);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--accent-soft);
    padding-bottom: 8px;
    text-align: left;
}

.desc-icon {
    width: 110px;
    height: 110px;
    margin-bottom: 15px;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
    transition: var(--smooth-transition);
}

.desc-icon:hover {
    transform: scale(1.05);
}

.original-work-sign {
    display: none;
    text-align: center;
    margin: 0 auto;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--smooth-transition);
}

a:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.version-text {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 500;
    opacity: 0.6;
    margin-top: -5px;
}

.footer-icons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 0px;
}

.footer-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.footer-icon {
    width: 70px;
    height: 70px;
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.footer-icon-link:hover .footer-icon {
    opacity: 1;
    transform: scale(1.12);
}

/* Mobile */
@media (max-width: 800px) {
    #values-container .category-section .values-flex-container {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 24px 10px;
        width: 100%;
        max-width: 100%;
        margin: 15px 0 0;
        justify-items: center;
        box-sizing: border-box;
    }
    .result-item {
        width: 100% !important;
        max-width: 105px;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        box-sizing: border-box;
    }
    .result-icon {
        width: 70px;
        height: 70px;
        margin-bottom: 6px;
        flex-shrink: 0;
    }
    .result-text {
        font-size: 0.68rem;
        line-height: 1.2;
        margin: 0;
        padding: 0 2px;
        width: 100%;
        box-sizing: border-box;
        overflow-wrap: anywhere;
        word-break: normal;
        hyphens: auto;
    }
    #ideologies-container .values-flex-container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        align-items: center !important;
        gap: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 15px 0 0 !important;
        box-sizing: border-box !important;
    }
    #ideologies-container .label-bubble {
        font-size: 0.88rem !important;
        padding: 8px 18px !important;
        margin: 3px !important;
        width: auto !important;
        max-width: 100% !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        line-height: 1.3 !important;
        border-radius: 50px !important;
        box-sizing: border-box !important;
        overflow-wrap: break-word !important;
        word-break: normal !important;
        hyphens: auto !important;
    }
    .label-bubble {
        font-size: 0.85rem;
        padding: 8px 16px;
        margin: 4px;
        width: auto;
        max-width: 90%;
        box-sizing: border-box;
        text-align: center;
    }
    #label {
        font-size: 1.4rem !important;
        padding: 12px 28px !important;
        margin: 15px 0 8px 0 !important;
        display: inline-block;
    }
    #secondary-label {
        font-size: 0.95rem !important;
        padding: 8px 18px !important;
        margin-top: 8px !important;
        display: inline-block;
    }
    .button-container {
        align-items: center;
    }
    #ideology-title {
        font-size: 1.8rem;
        margin-bottom: 15px;
        padding: 0 10px;
    }
    .license-bubble {
        width: 100% !important;
        max-width: 100vw;
        box-sizing: border-box;
        padding: 20px !important;
        margin: 20px 0 !important;
        border-radius: var(--radius-sm);
        height: auto;
        max-height: 65vh;
    }
    #license-text {
        white-space: pre-wrap !important;
        word-wrap: break-word;
        font-size: 0.85rem;
    }
    .category-title {
        font-size: 1.2rem;
        text-align: left;
        width: 100%;
    }
}

/* ---------- Closest matches (results page) ---------- */
#closest-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-top: 4px;
}

.closest-heading {
    margin: 6px 0 4px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
}

#closest-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Same look as the original "Next closest match": an outlined bubble in the ideology's color */
.closest-pill {
    display: inline-block;
    max-width: 100%;
    margin: 6px 0;
    padding: 14px 40px;
    border: 2px solid var(--pill-color, #7a7a7a);
    border-radius: 50px;
    background-color: transparent;
    color: var(--pill-color, #7a7a7a);
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
    transition: var(--smooth-transition);
}

.label-score,
.cp-score {
    white-space: nowrap;
}

.closest-pill:hover {
    color: var(--pill-color, #7a7a7a);
    text-decoration: none;
    filter: brightness(1.2);
}

@media (max-width: 800px) {
    .closest-pill {
        max-width: 90%;
        padding: 8px 18px;
        font-size: 0.95rem;
    }
}

/* ---------- Lists of values by category (results page and ideology page) ---------- */
.category-list {
    width: 100%;
}

#values-container .category-section {
    margin-bottom: 32px;
    scroll-margin-top: 12px;
}

.result-agree {
    margin: 2px 0 0;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    color: var(--text-dim);
}

.result-none {
    box-sizing: border-box;
    border: 2px dashed rgba(127, 127, 127, 0.55);
    border-radius: 50%;
    filter: none;
}

.result-none.add-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-none.add-icon::before {
    content: "+";
    font-size: 2rem;
    line-height: 1;
    color: var(--text-dim);
}

/* ---------- Results page: your closest ideologies, below the list ---------- */
.results-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 4px 0 8px;
}

/* ---------- Ideology page: value sets, browsed with the arrows ---------- */
.iv-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 14px 0 8px;
}

.iv-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.iv-arrow {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 0;
    padding: 0;
    border-radius: 50%;
    box-shadow: none;
    line-height: 1;
}

.iv-arrow::before {
    content: "";
    width: 10px;
    height: 10px;
    margin-left: 5px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
}

.iv-arrow-next::before {
    margin-left: 0;
    margin-right: 5px;
    transform: rotate(225deg);
}

.iv-dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 280px;
}

.iv-dot {
    width: 9px;
    height: 9px;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background-color: var(--text-dim);
    box-shadow: none;
    opacity: 0.4;
}

.iv-dot:hover {
    background-color: var(--text-dim);
    opacity: 0.8;
}

.iv-dot.active {
    background-color: var(--text-primary);
    opacity: 1;
}

.iv-caption {
    margin: 6px 0 22px;
    min-height: 1.2em;
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* ---------- Value page: slider from -1 to +1 ---------- */
.value-edit {
    width: 100%;
    justify-content: center;
}

.slider-block {
    --thumb: 26px;
    --track: 44px;
    width: 100%;
    max-width: 520px;
    margin: 4px 0 10px;
}

.slider-readout {
    text-align: center;
    margin-bottom: 4px;
}

.slider-number {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.slider-word {
    min-height: 1.4em;
    font-size: 0.95rem;
    color: var(--text-dim);
}

.slider {
    position: relative;
    height: var(--track);
    width: 100%;
}

.slider-bar {
    position: absolute;
    left: calc(var(--thumb) / 2);
    right: calc(var(--thumb) / 2);
    top: 50%;
    height: 8px;
    transform: translateY(-50%);
    background-color: #ffffff;
    border: 1px solid rgba(127, 127, 127, 0.6);
    border-radius: 5px;
    box-sizing: border-box;
}

.slider input[type="range"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    touch-action: pan-y;
}

.slider input[type="range"]::-webkit-slider-runnable-track {
    height: var(--track);
    background: transparent;
}

.slider input[type="range"]::-moz-range-track {
    height: var(--track);
    background: transparent;
}

.slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: var(--thumb);
    height: var(--thumb);
    margin-top: calc((var(--track) - var(--thumb)) / 2);
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #18181b;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

.slider input[type="range"]::-moz-range-thumb {
    width: var(--thumb);
    height: var(--thumb);
    box-sizing: border-box;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #18181b;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

.slider input[type="range"]:focus-visible {
    outline: none;
}

.slider input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--text-dim);
}

.slider input[type="range"]:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px var(--text-dim);
}

.slider-labels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 0 calc(var(--thumb) / 2);
    font-size: 0.85rem;
    line-height: 1.25;
    color: var(--text-dim);
}

.slider-labels span:nth-child(1) {
    text-align: left;
}

.slider-labels span:nth-child(2) {
    text-align: center;
}

.slider-labels span:nth-child(3) {
    text-align: right;
}

/* ---------- Wide screens: the lists use two columns, with room between them ---------- */
@media (min-width: 980px) {
    .category-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 64px;
        align-items: start;
    }
}

/* ---------- Phones and tablets ---------- */
@media (max-width: 800px) {
    .main-container {
        padding: 28px 16px;
    }

    .question-container {
        min-height: 0;
        margin-bottom: 14px;
    }

    #question {
        padding: 22px 20px;
        font-size: 1.15rem;
    }

    button {
        padding: 14px 18px;
        font-size: 1rem;
        line-height: 1.35;
    }

    #buttons {
        margin-top: 10px;
        margin-bottom: 30px;
    }

    .button-container button {
        min-width: min(220px, 100%);
    }
}

/* Touch screens: bigger slider, and no hover look left behind after a tap */
@media (pointer: coarse) {
    .slider-block {
        --thumb: 34px;
        --track: 56px;
    }
}

@media (hover: none) {
    button:hover {
        background-color: var(--card-bg);
        color: var(--text-primary);
        transform: none;
        box-shadow: none;
    }

    .result-item:hover .result-icon {
        transform: none;
    }
}

/* Download image: the button with the size menu next to it */
.download-row {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 10px;
    width: 100%;
}

.download-row select {
    padding: 0 12px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
}

.download-note {
    margin: -5px 0 0;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
}
