/* ---------------------------------------------------------------------------
   shorty — user facing page.
   Pico CSS provides the base; this file only adds the layout and the few
   components Pico has no opinion about.
   --------------------------------------------------------------------------- */

:root {
    --shorty-radius: 14px;
}

/*
 * Page width comes from Pico's `.container` and nothing else.
 *
 * There used to be a 46rem cap here as well, applied to the header, the footer
 * and `body > main`. Only two of the three ever took: `body > main` is a
 * (0,0,2) selector and Pico's `.container` is (0,1,0), so main kept Pico's
 * width while the header and footer shrank to 46rem — the header ended up
 * visibly inside the edges of the card below it. Anything that wants a
 * narrower column should say so on `.container` itself, so all three move
 * together.
 */

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body > main {
    flex: 1;
    padding-block: clamp(1.5rem, 6vw, 4rem);
}

/* ------------------------------------------------------------------ header */

/* Brand hard left, theme toggle hard right, on the same line as the edges of
   the card below. */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 1rem;
}

.app-header nav ul {
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.app-header nav li {
    padding: 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
    color: var(--pico-contrast);
}

.brand-icon {
    font-size: 28px;
    color: var(--pico-primary);
}

.icon-button {
    margin-bottom: 0;
    padding: 0.45rem 0.6rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

/* -------------------------------------------------------------------- hero */

.hero {
    text-align: center;
    margin-bottom: 2rem;
}

.hero h1 {
    margin-bottom: 0.35rem;
    font-size: clamp(1.7rem, 5vw, 2.6rem);
    line-height: 1.15;
}

.tagline {
    color: var(--pico-muted-color);
    margin: 0;
}

/* ------------------------------------------------------------ shorten card */

.shorten-card {
    border-radius: var(--shorty-radius);
    padding: clamp(1.25rem, 4vw, 2rem);
    margin-bottom: 2rem;
}

.input-row,
.result-row {
    display: flex;
    gap: 0.6rem;
    align-items: stretch;
}

.input-row input,
.result-row input {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
    /* Long URLs in any script must stay readable and never widen the layout. */
    text-overflow: ellipsis;
}

.input-row button,
.result-row button {
    margin-bottom: 0;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: auto;
}

.input-row button .material-symbols-rounded,
.result-row button .material-symbols-rounded {
    font-size: 20px;
}

.hint {
    display: block;
    margin-top: 0.6rem;
    color: var(--pico-muted-color);
}

.error {
    margin: 0.9rem 0 0;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    background: color-mix(in srgb, var(--pico-del-color) 14%, transparent);
    color: var(--pico-del-color);
    font-size: 0.9rem;
}

/* ------------------------------------------------------------------ result */

.result {
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--pico-muted-border-color);
}

.result h2 {
    font-size: 1rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pico-muted-color);
    margin-bottom: 0.75rem;
}

#result-url {
    font-weight: 600;
    font-size: 1.05rem;
    background: var(--pico-card-sectioning-background-color);
}

.result-target {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--pico-muted-color);
    word-break: break-all;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.1rem;
}

.result-actions > * {
    margin-bottom: 0;
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.result-actions .material-symbols-rounded {
    font-size: 20px;
}

button.copied {
    --pico-background-color: var(--pico-ins-color);
    --pico-border-color: var(--pico-ins-color);
}

/* ------------------------------------------------------------------ recent */

.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.recent-header h2 {
    font-size: 1rem;
    margin: 0;
    color: var(--pico-muted-color);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

button.small {
    margin-bottom: 0;
    width: auto;
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

button.small .material-symbols-rounded {
    font-size: 18px;
}

.recent-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recent-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 10px;
    background: var(--pico-card-background-color);
}

.recent-list .recent-body {
    flex: 1;
    min-width: 0;
}

.recent-list .recent-short {
    font-weight: 600;
    display: block;
    word-break: break-all;
}

.recent-list .recent-target {
    display: block;
    font-size: 0.8rem;
    color: var(--pico-muted-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-list button {
    margin: 0;
    padding: 0.35rem;
    width: auto;
    line-height: 1;
}

.muted {
    color: var(--pico-muted-color);
}

/* ------------------------------------------------------------------ footer */

.app-footer {
    padding-block: 1.5rem;
    text-align: center;
    color: var(--pico-muted-color);
}

/* ------------------------------------------------------------------ mobile */

@media (max-width: 640px) {
    .input-row,
    .result-row {
        flex-direction: column;
    }

    .input-row button,
    .result-row button {
        justify-content: center;
    }
}

/* Right-to-left languages only need the icon flips; Pico handles the rest. */
[dir="rtl"] .material-symbols-rounded[data-flip] {
    transform: scaleX(-1);
}
