/* ==========================================================================
   Tuple – tyylit
   Väri- ja typografiavalinnat on poimittu alkuperäisen sivuston kuvista.
   ========================================================================== */

/* Värit on mitattu alkuperäisen sivuston kuvakaappauksista pikselitasolla. */
:root {
    --blue: #296cc3;
    --blue-strong: #296cc3;
    --blue-dark: #20579f;
    --blue-soft: #e4eef9;
    --ink: #121826;
    --ink-2: #394150;
    --muted: #6c727f;
    --muted-2: #8a8f9a;
    --line: #d2d5db;
    --line-soft: #e5e7eb;
    --panel: #f9fafb;
    --callout: #f3f4f6;
    --white: #ffffff;
    --green: #188038;
    --green-soft: #e6f4ea;
    --red: #c5221f;
    --red-soft: #fce8e6;
    --amber: #e37400;
    --amber-soft: #fef7e0;

    /* Visualisointien värit (samat kuin alkuperäisissä piirroksissa) */
    --viz-line: #2b5fd9;
    --viz-fill: #dbe7f9;
    --viz-accent: #e8a13c;
    --viz-accent-line: #d98518;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(60, 64, 67, .1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 16px;
    color: var(--ink-2);
    background: var(--white);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
    color: var(--ink);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
    margin: 0;
}

:focus-visible {
    outline: 3px solid rgba(26, 115, 232, .45);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Yläpalkki ---------- */

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line-soft);
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 32px;
    height: 68px;
    display: flex;
    align-items: center;
    gap: 40px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    font-weight: 700;
    font-size: 21px;
    letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }

/* Umpinainen sininen ympyrä, jonka vasempaan puoliskoon on leikattu valkoinen
   puolisoikio. Mitat on otettu kuvakaappauksesta: sisennys vasemmalta 10 %,
   suora reuna keskellä (47,5 %), ylä- ja alasivennys 13,8 % halkaisijasta. */
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--blue);
    position: relative;
    overflow: hidden;
    flex: 0 0 auto;
}
.brand-mark::after {
    content: '';
    position: absolute;
    left: 10%;
    right: 52.5%;
    top: 13.8%;
    bottom: 13.8%;
    background: var(--white);
    border-radius: 100% 0 0 100% / 50% 0 0 50%;
}

.mainnav {
    display: flex;
    align-items: center;
    gap: 36px;
    flex: 1 1 auto;
}
.mainnav a {
    color: var(--ink);
    font-size: 15px;
    font-weight: 500;
}
.mainnav a:hover { color: var(--blue); text-decoration: none; }
.mainnav a.is-active { color: var(--blue); }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #c4c7c5;
    display: grid;
    place-items: center;
    color: #f1f3f4;
    flex: 0 0 auto;
    overflow: hidden;
}
.avatar svg { width: 36px; height: 36px; display: block; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--muted);
}

/* ---------- Sivupohja ---------- */

.page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 56px 32px 96px;
}

.page-narrow { max-width: 1000px; }

/* ---------- Kurssisivu ---------- */

/* Mitattu kuvakaappauksesta: vasen : oikea = 890 : 646 ≈ 1,38, väli 87/1623 ≈ 5,4 %. */
.course-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.38fr) minmax(0, 1fr);
    gap: 64px;
    align-items: start;
}

.course-hero {
    background: var(--callout);
    border-radius: var(--radius-lg);
    padding: 28px;
    display: grid;
    place-items: center;
}
.course-hero svg { width: 100%; height: auto; display: block; }

.course-title { font-size: 40px; margin-bottom: 20px; }

.course-lead { font-size: 16px; color: var(--ink-2); margin: 0 0 28px; }

.btn-soft {
    display: block;
    width: 100%;
    text-align: center;
    background: #f2f9ff;
    color: var(--blue-dark);
    font-weight: 600;
    font-size: 16px;
    padding: 16px 20px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
}
.btn-soft:hover { background: var(--blue-soft); text-decoration: none; }

.course-meta { margin-top: 36px; }
.course-meta hr { border: 0; border-top: 1px solid var(--line-soft); margin: 32px 0; }
.course-meta h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.course-meta p { font-size: 15px; color: var(--ink-2); margin: 0; }

.tabs {
    display: flex;
    gap: 32px;
    border-bottom: 1px solid var(--line-soft);
    margin: 48px 0 0;
}
.tab {
    padding: 12px 4px;
    font-size: 15px;
    font-weight: 500;
    color: var(--muted);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    background: none;
    cursor: pointer;
}
.tab.is-active { color: var(--blue); border-bottom-color: var(--blue); }
.tab:hover { text-decoration: none; }

.chapter-list {
    margin-top: 24px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    overflow: hidden;
}
.chapter-row {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) auto 32px;
    align-items: center;
    gap: 8px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line-soft);
    color: inherit;
}
.chapter-row:last-child { border-bottom: 0; }
.chapter-row:hover { background: #fafbfc; text-decoration: none; }
.chapter-icon {
    width: 56px; height: 56px;
    border-radius: var(--radius);
    background: var(--line-soft);   /* #e5e7eb – mitattu kuvakaappauksesta */
    display: grid; place-items: center;
    color: var(--muted);
}
.chapter-name {
    color: var(--blue);
    font-size: 15px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chapter-count { color: var(--muted); font-size: 15px; white-space: nowrap; }
.chapter-chevron { color: var(--muted-2); justify-self: end; }
.chapter-row.is-locked .chapter-name { color: var(--muted); }

/* ---------- Osiosivu ---------- */

/* Mitattu kuvakaappauksista: teksti : palkki = 1030 : 497 ≈ 2,07,
   väli erottimen ja palkin välissä 44/1613 ≈ 2,7 % käytettävissä olevasta leveydestä. */
.section-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 362px;
    gap: 32px;
    align-items: start;
}
.section-main { border-right: 1px solid var(--line-soft); padding-right: 34px; }

.section-title { font-size: 30px; }
.section-rule { border: 0; border-top: 1px solid var(--line-soft); margin: 18px 0 32px; }

.prose p { font-size: 17px; line-height: 1.75; margin: 0 0 22px; }
.prose p:last-child { margin-bottom: 0; }

.callout {
    background: var(--callout);
    border-radius: var(--radius);
    padding: 26px 30px;
    margin: 30px 0;
    text-align: center;
    font-size: 17px;
    line-height: 1.75;
}
.callout p { margin: 0 0 14px; }
.callout p:last-child { margin-bottom: 0; }
.callout .callout-title { font-weight: 700; color: var(--ink); }

.example {
    background: var(--callout);
    border-radius: var(--radius);
    padding: 26px 30px;
    margin: 30px 0;
    font-size: 17px;
    line-height: 1.75;
    text-align: left;
}
.example p { margin: 0 0 14px; }
.example p:last-child { margin-bottom: 0; }
.example strong { color: var(--ink); }

/* ---------- Oikea palkki ---------- */

.side-panel {
    background: var(--panel);
    border-radius: var(--radius-lg);
    padding: 24px 24px 28px;
    position: sticky;
    top: 92px;
}
.side-panel-head {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
}
.icon-btn {
    width: 34px; height: 34px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--white);
    display: grid; place-items: center;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover { background: var(--callout); }

.side-progress-label {
    text-align: center;
    font-size: 15px;
    color: var(--ink-2);
    margin-bottom: 16px;
}
/* Alkuperäisessä kaikki pallot ovat samanvärisiä; nykyinen osio on merkitty
   vain vaalealla renkaalla – ei siis omaa väriä tuleville osioille. */
.dots {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 26px;
}
.dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--blue);
    display: block;
}
.dot.is-current {
    box-shadow: 0 0 0 5px #c4dbfc;
}

/* Kysymysteksti on alkuperäisessä sisältöpalstan lopussa, ei oikeassa palkissa. */
.question-text {
    font-size: 17px;
    line-height: 1.75;
    color: var(--ink-2);
    margin: 22px 0 0;
}

.option {
    display: block;
    width: 100%;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 12px;
    font: inherit;
    font-size: 15px;
    color: var(--ink-2);
    text-align: center;
    cursor: pointer;
}
.option:hover { border-color: #b9c0c7; background: #fcfdff; }
.option.is-selected {
    border-color: var(--blue);
    box-shadow: inset 0 0 0 1px var(--blue);
    background: #f7fbff;
}
.option.is-correct { border-color: var(--green); background: var(--green-soft); }
.option.is-wrong { border-color: var(--red); background: var(--red-soft); }
.option[disabled] { cursor: default; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--blue-strong);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    padding: 15px 20px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { background: var(--blue-dark); text-decoration: none; color: #fff; }
.btn:disabled { background: #b7c8e4; cursor: default; }
.btn-ghost {
    background: var(--white);
    color: var(--ink-2);
    border: 1px solid var(--line);
    font-weight: 500;
}
.btn-ghost:hover { background: var(--callout); color: var(--ink-2); }
.btn + .btn { margin-top: 10px; }
.btn-inline { width: auto; padding: 12px 22px; }

.feedback {
    margin-top: 14px;
    font-size: 14px;
    border-radius: 6px;
    padding: 10px 14px;
}
.feedback.ok { background: var(--green-soft); color: var(--green); }
.feedback.no { background: var(--red-soft); color: var(--red); }

.side-note {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line-soft);
    font-size: 13px;
    color: var(--muted);
}

/* ---------- 3D-visualisointi ---------- */

.viz {
    margin: 34px 0;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--white);
}
.viz-stage {
    position: relative;
    height: 380px;
    background: linear-gradient(180deg, #fdfefe 0%, #f4f7fb 100%);
}
.viz-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.viz-badge {
    position: absolute;
    top: 12px; left: 14px;
    background: rgba(255, 255, 255, .88);
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12px;
    color: var(--muted);
    letter-spacing: .01em;
}
.viz-hint {
    position: absolute;
    right: 14px; bottom: 12px;
    font-size: 12px;
    color: var(--muted-2);
}
.viz-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 14px;
    color: var(--muted);
}

.viz-readouts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 20px 0;
}
.readout {
    background: var(--callout);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--ink-2);
}
.readout b { color: var(--ink); font-weight: 600; }

.viz-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px 24px;
    padding: 18px 20px 20px;
}
.control label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}
.control .value { color: var(--ink); font-weight: 600; }
.control input[type=range] {
    width: 100%;
    accent-color: var(--blue);
}
.control select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--white);
    font: inherit;
    font-size: 14px;
    color: var(--ink-2);
}
.control.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}
.control.toggle label { margin: 0; }

.viz-caption {
    padding: 0 20px 18px;
    font-size: 13px;
    color: var(--muted);
}

/* ---------- Koe ---------- */

.exam-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.eyebrow {
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.card {
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    padding: 28px 30px;
    background: var(--white);
}
.card + .card { margin-top: 20px; }
.card-title { font-size: 19px; margin-bottom: 8px; }

.grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
    gap: 32px;
    align-items: start;
}

.exam-progress {
    display: flex;
    gap: 6px;
    margin: 20px 0 28px;
}
.exam-progress span {
    height: 6px;
    flex: 1;
    border-radius: 3px;
    background: var(--line-soft);
}
.exam-progress span.done { background: var(--blue); }
.exam-progress span.current { background: var(--blue-strong); }

.question-block { font-size: 17px; line-height: 1.75; }
.question-block .q-lead { color: var(--ink); font-weight: 600; }

.answer-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 8px;
}
.answer-input {
    flex: 1 1 220px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    font-size: 17px;
    color: var(--ink);
}
.answer-input:focus { border-color: var(--blue); }

.solution {
    margin-top: 20px;
    background: var(--callout);
    border-radius: var(--radius);
    padding: 20px 24px;
    font-size: 16px;
    line-height: 1.7;
}
.solution h4 { font-size: 14px; margin-bottom: 10px; }

.result-banner {
    border-radius: var(--radius);
    padding: 14px 18px;
    font-size: 15px;
    margin-bottom: 16px;
    font-weight: 500;
}
.result-banner.ok { background: var(--green-soft); color: var(--green); }
.result-banner.no { background: var(--red-soft); color: var(--red); }

/* Osaamismittarit */
.skill-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 68px;
    gap: 14px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--line-soft);
}
.skill-row:last-child { border-bottom: 0; }
.skill-name { font-size: 15px; color: var(--ink); font-weight: 500; }
.skill-sub { font-size: 13px; color: var(--muted); }
.bar {
    height: 8px;
    border-radius: 4px;
    background: var(--line-soft);
    overflow: hidden;
    margin-top: 8px;
}
.bar > i {
    display: block;
    height: 100%;
    border-radius: 4px;
    background: var(--blue);
    transition: width .5s ease;
}
.bar.level-hallussa > i { background: var(--green); }
.bar.level-kehittyy > i { background: var(--blue); }
.bar.level-harjoiteltava > i { background: var(--amber); }
.bar.level-alustava > i { background: #9ec2f5; }
.skill-pct { text-align: right; font-size: 18px; font-weight: 700; color: var(--ink); }
.skill-pct small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }

.pill {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
}
.pill.hallussa { background: var(--green-soft); color: var(--green); }
.pill.kehittyy { background: var(--blue-soft); color: var(--blue-dark); }
.pill.harjoiteltava { background: var(--amber-soft); color: var(--amber); }
.pill.alustava, .pill.ei-dataa { background: var(--callout); color: var(--muted); }

.dial {
    display: grid;
    place-items: center;
    text-align: center;
}
.dial .num { font-size: 46px; font-weight: 700; color: var(--ink); line-height: 1; letter-spacing: -0.03em; }
.dial .lbl { font-size: 13px; color: var(--muted); margin-top: 6px; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th, .table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line-soft);
}
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

.katex { font-size: 1.03em; }
.katex-display { margin: 20px 0; }

/* ---------- Responsiivisuus ---------- */

@media (max-width: 1080px) {
    .course-grid { grid-template-columns: 1fr; gap: 40px; }
    .section-layout { grid-template-columns: 1fr; gap: 32px; }
    .section-main { border-right: 0; padding-right: 0; }
    .side-panel { position: static; }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .topbar-inner { padding: 0 16px; gap: 16px; height: 60px; }
    .mainnav { gap: 18px; overflow-x: auto; }
    .mainnav a { font-size: 14px; white-space: nowrap; }
    .page { padding: 32px 16px 72px; }
    .course-title { font-size: 30px; }
    .section-title { font-size: 24px; }
    .prose p, .callout, .example { font-size: 16px; }
    .chapter-row { grid-template-columns: 56px minmax(0, 1fr) 24px; }
    .chapter-icon { width: 44px; height: 44px; }
    .chapter-count { display: none; }
    .viz-stage { height: 300px; }
    .callout, .example { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

@media print {
    .topbar, .side-panel, .viz-controls { display: none; }
}
