/* ============================================================================
   Content pages: /tutorial, a tutorial article, and /updates.

   These pages are light only and use the town design language: the shared
   tokens and components (.town-block, .town-bubble, .town-btn)
   come from town.css, which loads before this file. Only page layout and the
   page-specific pieces live here.
   ============================================================================ */

/* Footer stays at the bottom on short pages. */
.content-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Auto side margins stop a flex item stretching, so the header would shrink
   to its content width here; give it the full row back. */
.content-body > .town-header { width: 100%; }

.content-page {
    flex: 1;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px 20px 120px;
    box-sizing: border-box;
}

.content-page a:focus-visible,
.content-page button:focus-visible {
    outline: 2px solid var(--town-purple);
    outline-offset: 3px;
}

/* ---- page head: sign, title, subtitle, filters; a scene on the right ---- */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
    padding-bottom: 48px;
}

.page-head h1 {
    margin-top: 22px;
    font-size: 48px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--town-ink);
}

.page-sub {
    margin-top: 10px;
    font-size: 18px;
    line-height: 1.5;
    color: var(--town-ink-2);
}

.page-head-scene { flex: none; }

.content-empty {
    padding: 28px 0;
    font-size: 15px;
    color: var(--town-ink-2);
}

/* ---- filters: the active chip is an ink pill, the rest sit on a soft underside ---- */

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 26px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 50px;
    background: #fff;
    color: #2d3140;
    box-shadow: 0 2px 0 rgba(22, 22, 26, 0.07);
    font: 600 13.5px 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.filter-chip:hover { background: var(--town-sky-2); }

.filter-chip.is-on {
    background: var(--town-ink);
    color: #fff;
}

/* How many tutorials a topic or tag holds. */
.chip-count {
    font-size: 12px;
    font-weight: 600;
}

.filter-chip .chip-count {
    padding: 1px 7px;
    border-radius: 50px;
    background: var(--town-sky-2);
    color: #5b3fc4;
}

.filter-chip.is-on .chip-count {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

/* ---- tag filters: one row of topics; a topic with several tags opens a quieter row of them ---- */

.tag-filters {
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Below the page head, across the full width: its own bottom padding sets the gap above. */
    margin: -20px 0 36px;
}

.tag-filters .filter-chips { margin-top: 0; }

.topic-tags {
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid rgba(22, 22, 26, 0.08);
    border-radius: 14px;
    background: #fff;
}

.topic-tags[hidden] { display: none; }

.filter-subchip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 50px;
    background: transparent;
    color: #2d3140;
    font: 600 13px 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.filter-subchip:hover { background: var(--town-sky-2); }

.filter-subchip .chip-count {
    color: var(--town-ink-3);
    font-weight: 500;
}

.filter-subchip.is-on {
    border-color: #7f5af0;
    background: #efeafe;
    color: #5b3fc4;
}

.filter-subchip.is-on .chip-count { color: #5b3fc4; }

.tutorial-result {
    margin: 2px 0 0;
    font-size: 14px;
    color: var(--town-ink-2);
}

/* Phones: each row scrolls sideways rather than wrapping into a wall of chips. */
@media (max-width: 640px) {
    .topic-chips,
    .topic-tags {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .topic-chips::-webkit-scrollbar,
    .topic-tags::-webkit-scrollbar { display: none; }

    .filter-chip,
    .filter-subchip {
        flex-shrink: 0;
        min-height: 44px;
    }
}

/* ---- tags on a card and on an article ---- */

.tutorial-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.tutorial-tags li {
    padding: 2px 9px;
    border-radius: 50px;
    background: var(--town-sky-2);
    color: #2d3140;
    font-size: 11.5px;
    font-weight: 600;
}

.tutorial-tags li.tutorial-tags-more {
    padding: 2px 4px;
    background: none;
    color: var(--town-ink-3);
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 26px 0 0;
}

.article-tag {
    padding: 4px 12px;
    border-radius: 50px;
    background: #fff;
    box-shadow: 0 2px 0 rgba(22, 22, 26, 0.07);
    color: #2d3140;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
}

.article-tag:hover { background: var(--town-sky-2); }

/* ---- tutorial index ---- */

.tutorial-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 44px 32px;
}

.tutorial-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--town-ink);
    text-decoration: none;
    transition: transform 0.2s var(--town-ease);
}

.tutorial-card:hover { transform: translateY(-3px); }
.tutorial-card[hidden] { display: none; }

.tutorial-thumb {
    position: relative;
    height: 210px;
    background: #221f33;
}

.tutorial-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tutorial-clips {
    position: absolute;
    left: 14px;
    bottom: 14px;
    --sw: var(--town-purple);
}

.tutorial-clips i { display: grid; place-items: center; }

.tutorial-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px 22px 22px;
}

.tutorial-card-body h2 {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.3;
}

.tutorial-card-body p {
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    color: var(--town-ink-2);
}

.tutorial-card-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px dashed rgba(22, 22, 26, 0.12);
    font-size: 13px;
    color: var(--town-ink-3);
}

.tutorial-live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 600;
    color: #137a50;
}

.tutorial-live i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.tutorial-start {
    font-weight: 700;
    color: var(--town-purple-ink);
}

/* ---- tutorial article ---- */

.article-page { max-width: 920px; }

.article-head { padding-bottom: 40px; }

.article-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--town-purple-ink);
    text-decoration: none;
}

.article-back:hover { color: #5236b8; }

.article-head h1 {
    margin-top: 20px;
    font-size: 46px;
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.02em;
}

.article-summary {
    margin-top: 16px;
    font-size: 18px;
    line-height: 1.6;
    color: var(--town-ink-2);
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.article-meta:empty { display: none; }

.article-demo-row { margin-top: 26px; }

.article-demo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
}

.article-steps {
    list-style: none;
    padding-top: 20px;
}

.article-step {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 24px;
}

/* The numbered stone with a dotted path running down to the next one. */
.article-step-route {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.article-step-route svg { flex: none; display: block; }

.article-step-path {
    flex: 1;
    width: 0;
    margin-top: 6px;
    border-left: 4px dotted #c9bdf0;
}

.article-step-body {
    min-width: 0;
    padding: 8px 0 56px;
}

.article-step-body h2 {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.article-step-body p {
    margin-top: 10px;
    font-size: 16px;
    line-height: 1.75;
    color: var(--town-ink-2);
}

.article-step-body ul {
    margin: 10px 0 0;
    padding-left: 22px;
    font-size: 16px;
    line-height: 1.7;
    color: var(--town-ink-2);
}

.article-step-body li + li { margin-top: 4px; }

/* Code in an article: a token, a field name, an address or a value (utils/tutorialText.js). */
.article-summary code,
.article-step-body code,
.article-media figcaption code,
.tutorial-card code {
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--town-sky-2);
    color: #4a2fb0;
    font: 500 0.88em/1.5 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow-wrap: anywhere;
}

.article-media { margin-top: 18px; }

.article-media-frame {
    padding: 10px;
    border-radius: 18px;
}

.article-media img,
.article-media video {
    display: block;
    width: 100%;
    border-radius: 12px;
    background: #221f33;
}

.article-media figcaption {
    margin-top: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--town-ink-3);
}

/* ---- updates ---- */

.release-log {
    display: flex;
    flex-direction: column;
    gap: 96px;
    padding-top: 20px;
}

.release {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 64px;
    align-items: start;
}

.release-side {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.release-version {
    font: 700 44px/1 'Space Grotesk', sans-serif;
    letter-spacing: -0.02em;
}

.release-date {
    font-size: 15px;
    color: var(--town-ink-2);
}

.release-scene {
    align-self: stretch;
    margin-top: 12px;
    border-radius: 22px;
    background: var(--town-sky-2);
}

.release-scene svg { margin: 0 auto; }

.release-main {
    display: flex;
    flex-direction: column;
    gap: 56px;
    min-width: 0;
}

.release-main .content-empty { padding: 0; }

.change-group {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.change-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.change-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--town-ink);
}

.change-title i { width: 8px; height: 8px; border-radius: 50%; background: var(--sw, var(--town-ink-3)); flex: none; }

.change-count {
    font-size: 13px;
    color: var(--town-ink-3);
}

/* Change category dots: Added green, Changed purple, Fixed amber, Security pink. */
.change-added { --sw: #2bb57e; }
.change-changed { --sw: #7f5af0; }
.change-fixed { --sw: #f2a93b; }
.change-security { --sw: #ef5b7b; }
.change-deprecated,
.change-removed { --sw: #9ca3af; }

.change-list { padding: 4px 26px; }

.change-item { padding: 16px 0; }

.change-item + .change-item { border-top: 1px solid rgba(22, 22, 26, 0.07); }

.change-item b {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 700;
}

.change-item p {
    margin-top: 6px;
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--town-ink-2);
}

/* ---- responsive ---- */

@media (max-width: 1100px) {
    .tutorial-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-head-scene { width: 300px; }
}

@media (max-width: 900px) {
    .release {
        grid-template-columns: minmax(0, 1fr);
        gap: 36px;
    }
    .release-scene { max-width: 320px; }
}

@media (max-width: 760px) {
    .page-head { display: block; padding-bottom: 36px; }
    .page-head-scene { display: none; }
    .page-head h1 { font-size: 38px; }
    .article-head h1 { font-size: 34px; }
}

@media (max-width: 640px) {
    .tutorial-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 32px;
    }
    .article-step {
        grid-template-columns: 52px minmax(0, 1fr);
        gap: 12px;
    }
    .article-step-route svg { width: 52px; height: auto; }
    .article-step-body { padding-bottom: 40px; }
    .article-step-body h2 { font-size: 20px; }
    .change-list { padding: 4px 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .tutorial-card,
    .filter-chip { transition: none; }
    .tutorial-card:hover { transform: none; }
}
