/* =========================================
   BASE
   ========================================= */

:root {
    --background: #ffffff;
    --ink: #222326;
    --muted: #737780;
    --border: #d9dce1;

    --dark: #292b2f;
    --dark-surface: #33363d;
    --dark-border: #464950;
    --dark-text: #f0f0f2;
    --dark-muted: #b7bac2;

    --green: #62d59a;
    --blue: #7da5cf;

    --jwt-header: #d9a69a;
    --jwt-payload: #a9b8d0;
    --jwt-signature: #b8b0cb;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font-family: "Inter", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
textarea {
    font: inherit;
}


/* =========================================
   HEADER
   ========================================= */

.site-header {
    width: min(100% - 48px, 1000px);
    margin: 0 auto;
    padding: 35px 0;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-family: "Bricolage Grotesque", sans-serif;
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: -0.2rem;
}

.site-logo strong {
    font-weight: 600;
}

.site-header nav a {
    font-size: 0.85rem;
    color: var(--muted);
}

.site-header nav a:hover {
    color: var(--ink);
}


/* =========================================
   TOKEN INPUT
   ========================================= */

.decoder-intro {
    max-width: 900px;
    min-height: 600px;
    margin: 0 auto;
    padding: 140px 24px 60px;
    text-align: center;
}

.decoder-intro h1 {
    margin: 0 0 36px;
    font-size: clamp(2.8rem, 5vw, 4rem);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.045em;
}

.token-input {
    max-width: 680px;
    margin: 0 auto;
}

.token-input textarea {
    display: block;
    width: 100%;
    min-height: 155px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--ink);
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
}

.token-input textarea::placeholder {
    color: #969ca8;
}

.token-input textarea:focus {
    outline: 2px solid #a5a0b9;
    outline-offset: 2px;
}

.input-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 24px;
}

.input-actions button {
    padding: 13px 23px;
    border: 0;
    border-radius: 5px;
    background: #222326;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.input-actions button:hover {
    background: #44464c;
}

.input-actions button:focus-visible {
    outline: 3px solid #a5a0b9;
    outline-offset: 3px;
}

.privacy-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
}


/* =========================================
   CURVED TRANSITION
   ========================================= */

.section-transition {
    width: 100%;
    height: 90px;
    line-height: 0;
    overflow: hidden;
}

.section-transition svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: var(--dark);
}


/* =========================================
   RESULTS
   ========================================= */

.results-section {
    background: var(--dark);
    color: var(--dark-text);
    padding: 50px 24px 100px;
}

.results-inner {
    max-width: 1000px;
    margin: 0 auto;
}

/* =========================================
   RESULTS HEADING
   ========================================= */

.results-heading {
    text-align: center;
    margin-bottom: 65px;
}

.results-heading h2 {
    margin: 0 0 12px;
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 500;
    letter-spacing: -0.04em;
}

.results-heading p {
    margin: 0;
    color: var(--dark-muted);
    font-size: 0.8rem;
}

.encoded-token {
    margin-bottom: 45px;
}

.encoded-token>span {
    display: block;
    margin-bottom: 10px;
    color: var(--dark-muted);
    font-size: 0.75rem;
}

.encoded-token-value {
    padding: 16px 20px;
    border-radius: 6px;
    background: #33363d;
}

.encoded-token-value code {
    display: block;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    color: #cbd3e0;
    font-size: 0.8rem;
}


/* =========================================
   TOKEN OVERVIEW
   ========================================= */

.token-overview {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 36px;
    align-items: center;
    margin-bottom: 65px;
}

.token-status {
    padding-right: 30px;
    border-right: 1px solid var(--dark-border);
}

.token-status>span {
    color: var(--dark-muted);
    font-size: 0.9rem;
}

.token-status h2 {
    margin: 5px 0 12px;
    color: var(--green);
    font-size: clamp(2.5rem, 4vw, 3.5rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.05em;
}

.token-status p {
    margin: 0 0 6px;
    font-size: 0.85rem;
}

.token-status small {
    color: var(--dark-muted);
    font-size: 0.75rem;
}

.overview-details {
    min-width: 0;
}

/* Encoded token */
.token-header {
    color: var(--jwt-header);
}

.token-payload {
    color: var(--jwt-payload);
}

.token-signature {
    color: var(--jwt-signature);
}

/* =========================================
   KEY CLAIMS
   ========================================= */

.key-claims {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.info-card {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 17px 14px;
    border: 1px solid #3b3e45;
    border-radius: 7px;
    background: var(--dark-surface);
}

.info-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;

    background: #a9b8d0;
    color: #222326;

    font-family: monospace;
    font-size: 0.7rem;
}

.info-card div {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.info-card small {
    color: var(--dark-muted);
    font-size: 0.7rem;
}

.info-card strong {
    font-size: 0.83rem;
    font-weight: 500;
    overflow-wrap: anywhere;
}


/* =========================================
   TOKEN LIFETIME
   ========================================= */

.lifetime h3 {
    margin: 0 0 22px;
    font-size: 0.9rem;
    font-weight: 500;
}

.timeline-track {
    position: relative;
    height: 9px;
    margin: 0 0 17px;
    border-radius: 4px;
    background: #4b5059;
}

.timeline-progress {
    width: 20.5%;
    height: 100%;
    border-radius: 4px 0 0 4px;
    background: var(--blue);
}

.timeline-marker {
    position: absolute;
    top: -7px;
    left: 20.5%;
    width: 2px;
    height: 23px;
    background: #a9c9eb;
    transform: translateX(-50%);
}

.timeline-marker::before,
.timeline-marker::after {
    content: "";
    position: absolute;
    left: 50%;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #a9c9eb;
    transform: translateX(-50%);
}

.timeline-marker::before {
    top: -3px;
}

.timeline-marker::after {
    bottom: -3px;
}

.timeline-labels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.timeline-labels>div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-labels strong {
    font-size: 0.75rem;
}

.timeline-labels span {
    color: var(--dark-muted);
    font-size: 0.72rem;
}

.timeline-now {
    text-align: center;
}

.timeline-end {
    text-align: right;
}


/* =========================================
   ACCORDIONS
   ========================================= */

.token-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.token-accordion {
    border: 1px solid var(--dark-border);
    border-radius: 8px;
    background: #303238;
    overflow: hidden;
}

.token-accordion summary {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 20px;
    padding: 14px 18px;
    cursor: pointer;
    list-style: none;
}

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

.token-accordion summary:hover {
    background: #383b42;
}

.token-accordion summary:focus-visible {
    outline: 2px solid #a9c9eb;
    outline-offset: -3px;
}

.accordion-name {
    display: flex;
    align-items: center;
    gap: 12px;
}

.accordion-name strong {
    display: inline-block;
    padding: 7px 12px;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.3;
}

.accordion-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
}

.header-icon {
    background: var(--jwt-header);
    color: #222326;
}

.payload-icon {
    background: var(--jwt-payload);
    color: #222326;
}

.signature-icon {
    background: var(--jwt-signature);
    color: #222326;
}

.accordion-description {
    color: var(--dark-muted);
    font-size: 0.8rem;
}

.accordion-arrow {
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--dark-muted);
    border-bottom: 2px solid var(--dark-muted);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.token-accordion[open] .accordion-arrow {
    transform: rotate(225deg);
}

.accordion-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 36px;
    padding: 24px 22px 28px;
    border-top: 1px solid var(--dark-border);
}

.accordion-explanation {
    padding: 5px 0;
}

.part-label {
    display: inline-block;
    padding: 7px 12px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 500;
}

.header-label {
    background: var(--jwt-header);
    color: #222326;
}

.payload-label {
    background: var(--jwt-payload);
    color: #222326;
}

.signature-label {
    background: var(--jwt-signature);
    color: #222326;
}

.accordion-explanation p {
    max-width: 330px;
    margin: 22px 0 0;
    color: var(--dark-muted);
    font-size: 0.9rem;
    line-height: 1.8;
}

.code-preview {
    min-width: 0;
    min-height: 160px;
    margin: 0;
    padding: 20px;
    border: 1px solid #42454d;
    border-radius: 6px;
    background: #383b43;
    color: #e4e9f4;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    overflow-x: auto;
}


/* =========================================
   COMMON CLAIMS
   ========================================= */

.claims-reference {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--dark-border);
}

.claims-reference h3 {
    flex-shrink: 0;
    margin: 0;
    font-size: 0.8rem;
    font-weight: 500;
}

.claims-list {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    flex-wrap: wrap;
    gap: 12px;
}

.claims-list span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--dark-muted);
    font-size: 0.75rem;
}

.claims-list code {
    padding: 6px 9px;
    border-radius: 5px;
    background: #383b43;
    color: #e1e7f3;
    font-size: 0.7rem;
}

.verification-note {
    margin: 32px 0 0;
    color: var(--dark-muted);
    font-size: 0.75rem;
    text-align: center;
}


/* =========================================
   ACCESSIBILITY
   ========================================= */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* Token input errors */
#token-error {
    max-width: 680px;
    margin: 20px auto 0;
    padding: 12px 16px;
    border-left: 3px solid #b45353;
    border-radius: 4px;
    background: #fdf3f3;
    color: #8c3030;
    font-size: 0.85rem;
    line-height: 1.6;
    text-align: left;
}

#token-error[hidden] {
    display: none;
}


/* =========================================
   RESPONSIVE
   ========================================= */

@media (max-width: 850px) {

    .token-overview {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .token-status {
        padding: 0 0 25px;
        border-right: none;
        border-bottom: 1px solid var(--dark-border);
    }

    .key-claims {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .claims-reference {
        align-items: flex-start;
        flex-direction: column;
        gap: 15px;
    }
}

@media (max-width: 650px) {

    .site-header {
        width: min(100% - 40px, 1000px);
        padding: 25px 0;
    }

    .decoder-intro {
        min-height: 650px;
        padding: 85px 20px 55px;
    }

    .decoder-intro h1 {
        font-size: clamp(2.5rem, 8vw, 3.5rem);
    }

    .input-actions {
        gap: 14px;
    }

    .section-transition {
        height: 55px;
    }

    .results-section {
        padding: 75px 20px 80px;
    }

    .results-heading {
        margin-bottom: 45px;
    }

    .key-claims {
        grid-template-columns: 1fr;
    }

    .token-accordion summary {
        grid-template-columns: 1fr 20px;
        gap: 12px;
    }

    .accordion-description {
        display: none;
    }

    .accordion-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .code-preview {
        min-height: 0;
    }

    .claims-list {
        justify-content: flex-start;
    }
}

@media (max-width: 420px) {

    .decoder-intro {
        padding-top: 75px;
    }

    .decoder-intro h1 {
        font-size: 2.5rem;
    }

    .input-actions {
        flex-direction: column;
    }

    .timeline-labels span {
        font-size: 0.65rem;
    }
}