/* /download (the installer) and /setup (the walkthrough after it).
   Page layer for css/tg.css: --tg-* tokens only, .tg-dl-* and .tg-setup-* names. This file
   loads BEFORE tg.css, so any rule that refines a tg.css component is scoped under a
   page class to outrank it. */

/* ===== Shared ========================================================= */
/* Rules that refine a tg.css component repeat its class (.tg-section.tg-dl) so they
   win despite loading first. */

.tg-dl b,
.tg-dl-more b,
.tg-setup b {
    color: #ffffff;
    font-weight: 600;
}

.tg-dl code,
.tg-dl-more code,
.tg-setup code {
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--tg-surface-2);
    color: #ffffff;
    font-family: var(--tg-font-mono);
    font-size: 0.92em;
    overflow-wrap: anywhere;
}

/* Anything a link or the hash can land on clears the sticky header. */
.tg-dl [id],
.tg-dl-more [id],
body[data-page='download'] main > section[id],
.tg-setup [id],
body[data-page='setup'] main > section[id] {
    scroll-margin-top: 96px;
}

/* ===== Installer: one screen ========================================== */

.tg-section.tg-dl {
    padding-top: clamp(28px, 4vw, 56px);
    padding-bottom: clamp(40px, 5vw, 64px);
}

.tg-dl-flow {
    display: flex;
    flex-direction: column;
    gap: var(--tg-space-6);
    counter-reset: tg-dl-stage;
}

.tg-dl-intro {
    display: flex;
    flex-direction: column;
    gap: var(--tg-space-3);
}

.tg-dl-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--tg-space-2) var(--tg-space-5);
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--tg-text-soft);
    font-size: var(--tg-size-small);
}

.tg-dl-meta li {
    position: relative;
    padding-left: 18px;
}

.tg-dl-meta li::before {
    content: '';
    position: absolute;
    top: 0.5em;
    left: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tg-success);
}

/* A hidden stage (iPhone or Mac chosen) is display: none, so it does not count: the
   numbers stay 1, 2, 3 whatever is shown. */
.tg-dl-stage {
    display: flex;
    flex-direction: column;
    gap: var(--tg-space-3);
    min-width: 0;
    counter-increment: tg-dl-stage;
}

.tg-dl-stage-title {
    display: flex;
    align-items: center;
    gap: var(--tg-space-3);
    margin: 0;
    color: #ffffff;
    font-family: var(--tg-font-display);
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.2;
}

.tg-dl-stage-title::before {
    content: counter(tg-dl-stage);
    display: grid;
    flex: none;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--tg-blue-soft);
    color: #c6d1ff;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0;
}

/* ===== 1. Device row ================================================== */

.tg-dl-devices {
    display: grid;
    gap: var(--tg-space-2);
    margin: 0;
    padding: 0;
    list-style: none;
    grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
}

.tg-dl .tg-choice {
    height: 100%;
    min-height: 56px;
    padding: 8px 14px 8px 10px;
    text-decoration: none;
}

.tg-dl .tg-choice .tg-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.tg-dl .tg-choice .tg-icon svg {
    width: 20px;
    height: 20px;
}

.tg-dl .tg-choice strong {
    font-size: 0.98rem;
    line-height: 1.25;
}

/* The links carry the choice as aria-current (js/tg-download.js), styled as tg.css styles
   a pressed choice. Without the script no card is marked. */
.tg-dl .tg-choice[aria-current='true'] .tg-icon {
    background: var(--tg-blue);
    color: #ffffff;
}

/* ===== 2 + 3. Code beside the steps =================================== */

.tg-dl-install {
    display: grid;
    gap: var(--tg-space-6);
    align-items: start;
}

/* Narrow phones: one compact column, so no label breaks over three lines. */
@media (max-width: 480px) {
    .tg-dl-devices {
        grid-template-columns: minmax(0, 1fr);
    }

    .tg-dl-devices .tg-choice {
        min-height: 52px;
        padding-block: 8px;
    }
}

@media (min-width: 900px) {
    .tg-dl-install {
        grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    }

    /* iPhone or Mac: no code card, so the steps take the whole row. */
    .tg-dl[data-dl-device-selected='iphone'] .tg-dl-install,
    .tg-dl[data-dl-device-selected='mac'] .tg-dl-install {
        grid-template-columns: minmax(0, 1fr);
        max-width: 760px;
    }
}

.tg-dl .tg-dl-app {
    gap: var(--tg-space-4);
}

.tg-dl-app-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--tg-space-2);
}

.tg-dl-app-top h3:focus {
    outline: none;
}

.tg-dl-method {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    min-width: 0;
}

.tg-dl-method--direct .tg-btn {
    align-self: flex-start;
}

/* On a phone the file itself is the method, so it leads. */
.tg-dl[data-dl-device-selected='android-phone'] .tg-dl-method--direct {
    order: -1;
}

.tg-dl[data-dl-device-selected='android-phone'] .tg-dl-app-top {
    order: -2;
}

.tg-dl .tg-code {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    max-width: 100%;
}

.tg-dl .tg-code-value {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* No numeric code in the feed: js/download.js shows the address instead. */
.tg-dl .tg-code.no-code .tg-code-value {
    font-size: 1.15rem;
    letter-spacing: 0;
}

.tg-dl-version:empty {
    display: none;
}

.tg-dl .tg-dl-switch {
    margin: 0;
    padding-top: var(--tg-space-3);
    border-top: 1px solid var(--tg-line);
    color: var(--tg-text-soft);
}

.tg-dl-switch a,
.tg-dl-same a {
    color: #c6d1ff;
    font-weight: 600;
}

.tg-dl-same {
    margin: 0;
}

/* Without the script both app cards are listed, so separate them. */
.tg-dl:not(.is-enhanced) .tg-dl-app + .tg-dl-app {
    margin-top: var(--tg-space-2);
}

.tg-dl-panel {
    display: flex;
    flex-direction: column;
    gap: var(--tg-space-3);
}

/* Without the script every panel is listed, so separate them. */
.tg-dl:not(.is-enhanced) .tg-dl-panel + .tg-dl-panel {
    margin-top: var(--tg-space-4);
    padding-top: var(--tg-space-5);
    border-top: 1px solid var(--tg-line);
}

.tg-dl-panel-title {
    margin: 0;
    color: var(--tg-text-soft);
    font-family: var(--tg-font-body);
    font-size: var(--tg-size-small);
    font-weight: 600;
}

.tg-dl-panel-lede {
    margin: 0;
    color: var(--tg-text-soft);
}

/* Compact steps: the whole journey should fit in about one screen. */
.tg-dl .tg-steps {
    gap: var(--tg-space-2);
}

.tg-dl .tg-steps > li {
    gap: 2px;
    padding: 12px 16px 12px 58px;
}

.tg-dl .tg-steps > li::before {
    top: 12px;
    left: 14px;
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
}

.tg-dl-appstore {
    display: flex;
    flex-direction: column;
    gap: var(--tg-space-2);
}

.tg-dl-appstore .app-store-badge {
    display: inline-flex;
    align-self: flex-start;
    min-height: 48px;
}

.tg-dl-appstore .app-store-credit {
    margin: 0;
    max-width: 60ch;
}

.tg-dl-next {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--tg-space-3) var(--tg-space-5);
    padding-top: var(--tg-space-5);
    border-top: 1px solid var(--tg-line);
}

.tg-dl-next p {
    flex: 1 1 360px;
    margin: 0;
    color: var(--tg-text-soft);
}

.tg-dl-next strong {
    color: #ffffff;
}

/* ===== More options (folded) ========================================== */

.tg-wrap.tg-dl-more-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--tg-space-4);
    max-width: 880px;
}

.tg-dl-refused p,
.tg-dl-official p {
    margin: 0;
}

.tg-dl-more .tg-faq-body {
    display: flex;
    flex-direction: column;
    gap: var(--tg-space-3);
}

.tg-dl-more .tg-faq-body p {
    margin: 0;
}

.tg-dl-more .tg-faq-body a:not(.tg-btn) {
    color: #c6d1ff;
}

.tg-dl-sub {
    margin: var(--tg-space-2) 0 0;
    color: #ffffff;
    font-family: var(--tg-font-display);
    font-size: 1rem;
    font-weight: 600;
}

.tg-dl-sub:first-child {
    margin-top: 0;
}

.tg-dl-qa dl {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
}

.tg-dl-qa dt {
    margin-top: var(--tg-space-2);
    color: var(--tg-text);
    font-weight: 600;
}

.tg-dl-qa dt:first-child {
    margin-top: 0;
}

.tg-dl-qa dd {
    display: flex;
    flex-direction: column;
    gap: var(--tg-space-2);
    margin: 0;
}

.tg-dl-list {
    display: flex;
    flex-direction: column;
    gap: var(--tg-space-3);
    margin: 0;
    padding-left: 1.1em;
    color: var(--tg-text-soft);
}

.tg-dl-list li::marker {
    color: var(--tg-text-faint);
}

/* ===== Version history ================================================ */

.tg-dl-release-list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tg-dl-release {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--tg-space-3);
    padding: var(--tg-space-3) 0;
    border-bottom: 1px solid var(--tg-line);
}

.tg-dl-release:last-child {
    border-bottom: 0;
}

.tg-dl-release > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tg-dl-release :is(h3, p) {
    margin: 0;
}

#downloadLatest .tg-dl-release {
    padding: var(--tg-space-4);
    border: 1px solid var(--tg-line-strong);
    border-radius: var(--tg-radius);
    background: var(--tg-surface-2);
}

.tg-dl-release-meta {
    color: var(--tg-text-soft);
    font-size: var(--tg-size-small);
}

.tg-dl-whatsnew :is(h3, p, ul) {
    margin: 0;
}

.tg-dl-whatsnew .changelog-body {
    display: flex;
    flex-direction: column;
    gap: var(--tg-space-2);
    color: var(--tg-text-soft);
}

.tg-dl-whatsnew .changelog-bullets {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 1.1em;
}

.tg-dl-whatsnew .changelog-version {
    display: inline-flex;
    padding: 4px 10px;
    border: 1px solid rgb(61 99 255 / 45%);
    border-radius: var(--tg-radius-pill);
    background: var(--tg-blue-soft);
    color: #c6d1ff;
    font-family: var(--tg-font-display);
    font-size: 0.8rem;
    font-weight: 600;
}

/* ===== Setup page ===================================================== */

.tg-section.tg-setup-hero {
    padding-top: clamp(28px, 4vw, 64px);
    padding-bottom: clamp(32px, 4vw, 56px);
}

.tg-setup-facts {
    display: grid;
    gap: var(--tg-space-4);
    margin: 0;
    padding: 0;
    list-style: none;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
}

.tg-setup-facts li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--tg-text-soft);
    font-size: var(--tg-size-small);
}

.tg-setup-facts strong {
    color: #ffffff;
    font-family: var(--tg-font-display);
    font-size: 1rem;
    font-weight: 600;
}

.tg-setup .tg-steps,
.tg-setup .tg-faq,
.tg-setup-note {
    max-width: 880px;
}

.tg-setup .tg-steps {
    gap: var(--tg-space-2);
}

.tg-setup .tg-steps > li {
    gap: 2px;
    padding: 14px 18px 14px 62px;
}

.tg-setup .tg-steps > li::before {
    top: 13px;
    left: 16px;
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
}

.tg-setup-types .tg-card {
    gap: var(--tg-space-2);
}

.tg-setup-types .tg-badge {
    align-self: flex-start;
}

.tg-setup-note {
    margin-top: var(--tg-space-5);
}

.tg-setup-note p {
    margin: 0;
}

.tg-setup .tg-faq-body .tg-ticks {
    margin: 0;
}

.tg-setup-help {
    margin-top: var(--tg-space-5);
}
