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

/* Shared styles for the long-form pages: the Teacher's AI Toolkit and the blog. */

/* Theme variables – kept in sync with ../index.html (palette shared with the slide decks) */

/* Warm (default) */
:root {
    --font-heading: 'Newsreader', Georgia, serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --bg-primary: #F4EFE8;
    --bg-secondary: #FFFFFF;
    --bg-hover: #F8E6DF;

    --text-primary: #1F1B17;
    --text-secondary: #5A5A5A;
    --text-tertiary: #5A5A5A;

    --accent-color: #9A3620;
    --border-color: #CFC6BA;

    --card-bg: #FFFFFF;
    --card-hover: #F8E6DF;
}

/* Clear */
[data-theme="clear"] {
    --font-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --bg-primary: #FFFFFF;
    --bg-secondary: #FFFFFF;
    --bg-hover: #F8E6DF;

    --text-primary: #1F1B17;
    --text-secondary: #5A5A5A;
    --text-tertiary: #5A5A5A;

    --accent-color: #74281A;
    --border-color: #CFC6BA;

    --card-bg: #F4EFE8;
    --card-hover: #F8E6DF;
}

/* Dark */
[data-theme="dark"] {
    --bg-primary: #1F1B17;
    --bg-secondary: #2A2521;
    --bg-hover: #3D3631;

    --text-primary: #F4EFE8;
    --text-secondary: #C9C4BD;
    --text-tertiary: #C9C4BD;

    --accent-color: #F0A083;
    --border-color: #3D3631;

    --card-bg: #2A2521;
    --card-hover: #342E29;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

button,
input,
select {
    font-family: inherit;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

a:hover {
    text-decoration: none;
}

/* Reading progress */
.progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: var(--accent-color);
    transform-origin: 0 50%;
    transform: scaleX(0);
    z-index: 1001;
}

/* Layout – one centred reading column */
.layout {
    max-width: 784px;
    margin: 0 auto;
    padding: 64px 32px 120px;
}

.back-link {
    display: inline-block;
    font-size: 14px;
    margin-bottom: 40px;
}

/* Collapsible contents list after the introduction (phones and tablets) */
.contents-part:first-child {
    margin-top: 0;
}

.prose .contents ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

.prose .contents li {
    margin: 0;
}

.contents a {
    text-decoration: none;
}

.contents a:hover {
    text-decoration: underline;
}

.contents-part {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--accent-color);
    margin: 28px 0 10px;
}

.prose .contents .contents-h2 {
    margin-bottom: 14px;
}

.contents-h2 > a {
    font-weight: 600;
}

.prose .contents .contents-sub {
    margin-top: 6px;
    padding-left: 16px;
    border-left: 1px solid var(--border-color);
}

.prose .contents .contents-sub li {
    margin-bottom: 4px;
}

.contents-sub a {
    font-size: 15px;
    color: var(--text-secondary);
}

.contents-scenario a::before {
    content: "▸ ";
    color: var(--accent-color);
}

/* Contents: a sidebar on desktop, a bottom sheet opened from the ☰ button on phones and tablets */
.toc {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 75vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
    padding: 20px 16px 32px;
    font-size: 14px;
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
    z-index: 1003;
}

body.toc-open .toc {
    transform: none;
    visibility: visible;
    transition: transform 0.25s ease;
}

.toc-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.toc-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 8px;
}

.toc ol {
    list-style: none;
}

.toc a {
    display: block;
    text-decoration: none;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-left: 2px solid var(--border-color);
    line-height: 1.35;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.toc a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.toc-part {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--accent-color);
    padding: 20px 0 6px 12px;
}

.toc-part:first-child {
    padding-top: 4px;
}

.toc-h2 > a {
    font-weight: 500;
}

.toc-sub {
    display: none;
    margin-bottom: 4px;
}

.toc-h2.is-open > .toc-sub {
    display: block;
}

.toc-sub a {
    padding-left: 24px;
    font-size: 13px;
}

.toc-sub .toc-scenario a::before {
    content: "▸ ";
    color: var(--accent-color);
}

.toc a.is-current {
    color: var(--text-primary);
    border-left-color: var(--accent-color);
    font-weight: 600;
}

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    z-index: 1002;
}

body.toc-open .scrim {
    opacity: 1;
    pointer-events: auto;
}

body.toc-open {
    overflow: hidden;
}

/* Article */
.article {
    max-width: 720px;
}

.article-header {
    margin-bottom: 56px;
}

.label {
    display: inline-block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 16px;
}

.article-header h1 {
    font-family: var(--font-heading);
    font-size: 48px;
    line-height: 1.15;
    font-weight: bold;
    margin-bottom: 20px;
}

.subtitle {
    font-size: 19px;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.byline {
    font-size: 14px;
    color: var(--text-tertiary);
}

.prose {
    font-size: 17px;
    line-height: 1.7;
}

.prose p,
.prose ul,
.prose ol {
    margin-bottom: 1.1em;
}

.prose ul,
.prose ol {
    padding-left: 1.4em;
}

.prose li {
    margin-bottom: 0.4em;
}

.prose h2,
.prose h3,
.prose h4 {
    font-family: var(--font-heading);
    position: relative;
    scroll-margin-top: 24px;
}

.prose h2 {
    font-size: 34px;
    line-height: 1.2;
    margin: 80px 0 24px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.prose h3 {
    font-size: 24px;
    line-height: 1.3;
    margin: 48px 0 16px;
}

.prose h4 {
    font-size: 19px;
    line-height: 1.35;
    margin: 36px 0 12px;
}

.anchor {
    display: inline-block;
    margin-left: 10px;
    color: var(--text-tertiary);
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.anchor svg {
    display: block;
    width: 0.6em;
    height: 0.6em;
    transform: translateY(0.1em);
}

.prose h2:hover .anchor,
.prose h3:hover .anchor,
.prose h4:hover .anchor,
.anchor:focus {
    opacity: 1;
}

.anchor:hover {
    color: var(--accent-color);
}

/* Figures – the images have white backgrounds, so keep them on white in every theme */
.figure {
    margin: 32px 0;
}

.figure a {
    display: block;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.figure img {
    display: block;
    width: 100%;
    height: auto;
}

.figure figcaption {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-top: 12px;
}

/* How to cite */
.cite-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin: 32px 0 0;
    font-size: 15px;
    line-height: 1.6;
}

.prose .cite-box p {
    margin-bottom: 12px;
}

.cite-title {
    font-weight: 600;
}

.cite-text a {
    overflow-wrap: anywhere;
}

.cite-copy {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 16px;
}

.cite-copy:hover {
    background: var(--bg-hover);
}

.prose .cite-box .cite-license {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.cite-license a {
    color: var(--text-secondary);
}

/* Scenarios */
.prose details {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin: 32px 0;
    scroll-margin-top: 24px;
}

.prose summary {
    cursor: pointer;
    list-style: none;
    padding: 18px 48px 18px 20px;
    font-weight: 600;
    font-size: 17px;
    line-height: 1.4;
    position: relative;
}

.prose summary::-webkit-details-marker {
    display: none;
}

.prose summary::after {
    content: "+";
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 22px;
    font-weight: 400;
    color: var(--accent-color);
}

.prose details[open] summary::after {
    content: "–";
}

.prose summary:hover {
    background: var(--card-hover);
    border-radius: 12px;
}

.scenario-tag {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-color);
    margin-bottom: 4px;
}

.prose details > :not(summary) {
    margin-left: 20px;
    margin-right: 20px;
}

.prose details > :last-child {
    margin-bottom: 20px;
}

.prose details[open] > summary {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

/* Disclosure example and other quoted italics */
.prose em {
    font-style: italic;
}

/* References */
#references ~ p {
    font-size: 15px;
    line-height: 1.55;
    padding-left: 1.5em;
    text-indent: -1.5em;
    margin-bottom: 0.8em;
    overflow-wrap: anywhere;
}

/* Floating controls */
.theme-switcher {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.theme-switcher:hover {
    background: var(--card-hover);
    transform: scale(1.1);
}

.to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 20px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, background 0.2s;
    z-index: 1000;
}

.to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.to-top:hover {
    background: var(--card-hover);
}

.toc-toggle {
    position: fixed;
    right: 24px;
    bottom: 84px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, background 0.2s;
}

.toc-toggle.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.toc-toggle:hover {
    background: var(--card-hover);
}

.toc-toggle svg {
    width: 20px;
    height: 20px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 88px;
    transform: translate(-50%, 8px);
    background: var(--text-primary);
    color: var(--bg-primary);
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 50px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1002;
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Tablet and phone: the contents panel becomes a bottom sheet */
@media (max-width: 1023px) {
    .layout {
        padding: 72px 16px 120px;
    }

    .back-link {
        margin-bottom: 32px;
    }

    .toc a {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .toc-toggle {
        right: 16px;
    }

    .theme-switcher {
        top: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .to-top {
        right: 16px;
    }

    .article-header h1 {
        font-size: 34px;
    }

    .subtitle {
        font-size: 17px;
    }

    .prose {
        font-size: 16px;
    }

    .prose h2 {
        font-size: 27px;
        margin-top: 56px;
    }

    .prose h3 {
        font-size: 21px;
    }

}

/* Desktop: contents as a sticky sidebar next to the text */
@media (min-width: 1024px) {
    .layout {
        max-width: 1200px;
        display: grid;
        grid-template-columns: 260px minmax(0, 1fr);
        gap: 64px;
    }

    .back-link {
        grid-column: 1 / -1;
        margin-bottom: 0;
    }

    .toc {
        position: sticky;
        top: 32px;
        align-self: start;
        max-height: calc(100vh - 64px);
        padding: 0 8px 0 0;
        background: none;
        border-radius: 0;
        box-shadow: none;
        transform: none;
        visibility: visible;
        transition: none;
        z-index: auto;
    }

    .toc a {
        padding: 6px 12px;
    }

    .toc-sub a {
        padding-left: 24px;
    }

    .toc-close,
    .toc-toggle,
    .scrim,
    .prose .contents {
        display: none;
    }
}

/* Touch screens can't hover, so the copy-link buttons are left out there */
@media (hover: none) {
    .anchor {
        display: none;
    }
}

@media print {
    .toc, .toc-toggle, .theme-switcher, .to-top, .progress, .back-link, .anchor, .cite-copy {
        display: none !important;
    }

    .layout {
        display: block;
        padding: 0;
    }

    .prose details > * {
        display: block;
    }
}

/* ----------------------------------------------------------------------------
   Blog
   ---------------------------------------------------------------------------- */

/* Language label (EN / FI) */
.lang-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    line-height: 1;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 3px 7px;
    margin-left: 4px;
    vertical-align: 0.1em;
}

/* Sidebar: the posts, with the headings of the current one under it */
.toc-post.is-current-post > a {
    color: var(--text-primary);
    border-left-color: var(--accent-color);
    font-weight: 600;
}

.toc-post.is-current-post > .toc-sub {
    display: block;
}

.toc-all {
    display: inline-block;
    margin: 16px 0 0 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-color);
    text-decoration: none;
}

.toc .toc-all {
    border-left: none;
    padding: 0;
}

.toc .toc-all:hover {
    background: none;
    color: var(--accent-color);
    text-decoration: underline;
}

/* Quotes */
.prose blockquote {
    border-left: 3px solid var(--accent-color);
    padding: 4px 0 4px 20px;
    margin: 32px 0;
    font-family: var(--font-heading);
    font-size: 1.2em;
    line-height: 1.5;
}

.prose blockquote p:last-child {
    margin-bottom: 0;
}

/* Citation at the end of a post */
.post-cite {
    margin-top: 64px;
}

/* The list of posts */
.post-list {
    list-style: none;
    border-top: 1px solid var(--border-color);
}

.post-item {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 24px;
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
}

.post-date {
    font-size: 14px;
    color: var(--text-secondary);
    padding-top: 5px;
}

.post-title {
    font-family: var(--font-heading);
    font-size: 23px;
    line-height: 1.3;
    font-weight: 600;
    text-decoration: none;
}

.post-title:hover {
    text-decoration: underline;
}

.post-summary {
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-secondary);
    margin-top: 6px;
}

.post-empty {
    color: var(--text-secondary);
}

@media (max-width: 1023px) {
    .post-item {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
        padding: 20px 0;
    }

    .post-date {
        padding-top: 0;
    }

    .post-title {
        font-size: 20px;
    }
}

/* The list page has no sidebar, so it keeps one centred column on desktop */
@media (min-width: 1024px) {
    .layout.layout-single {
        max-width: 784px;
        display: block;
    }

    .layout-single .back-link {
        margin-bottom: 40px;
    }
}
