/* =========================
   Base reset
========================= */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #2b3853;
    color: #222;
    margin: 0;
    padding: 0;
}

/* =========================
   Hero / first screen
========================= */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* Main container */
.container {
    max-width: 720px;
    width: 100%;
    background: #fff;
    padding: 2rem 2.25rem;
    border-radius: 8px;
    box-shadow: 0 0 29px rgba(0, 0, 0, 0.6);
}

/* Optional content below the fold */
.content {
    max-width: 720px;
    margin: 0 auto 3rem;
    background: #fff;
    padding: 2rem 2.25rem;
    border-radius: 8px;
}

/* =========================
   Header
========================= */
.header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.header img {
    display: block;
    margin: 0 auto 0.75rem;
}

h1 {
    margin: 0.35rem 0 0;
    font-size: 1.65rem;
}

h2 {
    margin: 1.75rem 0 0.5rem;
    font-size: 1.05rem;
}

.beta-badge {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: #555;
}

.brand-name {
    margin: 0;
    color: #2b3853;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.hero-intro {
    max-width: 560px;
    margin: 0.75rem auto 0;
    color: #4a5568;
    line-height: 1.5;
}

/* Screen-reader-only helper */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================
   Form elements
========================= */
form {
    margin-top: 1.5rem;
}

fieldset {
    min-width: 0;
}

label {
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.link-type {
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
}

.link-type legend {
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.link-type-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.link-type-toggle label {
    margin: 0;
    cursor: pointer;
}

.link-type-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.link-type-toggle span {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    padding: 0.65rem;
    border: 2px solid #687386;
    border-radius: 6px;
    text-align: center;
}

.link-type-toggle input:checked + span {
    border-color: #2b3853;
    background: #2b3853;
    color: #fff;
}

.link-type-toggle input:focus-visible + span {
    outline: 3px solid #06f;
    outline-offset: 2px;
}

.link-type-help {
    margin: 0.55rem 0 0;
    color: #555;
    font-size: 0.9rem;
}

.field-help {
    margin: 0.4rem 0 0;
    color: #555;
    font-size: 0.9rem;
    line-height: 1.4;
}

.turnstile-field {
    margin: 1.15rem 0 0;
    padding: 0.9rem 1rem;
    border: 1px solid #cbd3df;
    border-radius: 6px;
    background: #f8fafc;
}

.turnstile-field legend {
    padding: 0 0.3rem;
    font-weight: 600;
}

.turnstile-widget {
    display: flex;
    width: 100%;
    min-height: 65px;
    align-items: center;
    justify-content: center;
}

.turnstile-widget .cf-turnstile {
    width: 100%;
    max-width: 400px;
}

.turnstile-loading {
    color: #555;
    font-size: 0.9rem;
}

.turnstile-help,
.turnstile-status,
.turnstile-noscript {
    margin: 0.55rem 0 0;
    text-align: center;
    font-size: 0.9rem;
}

.turnstile-help {
    color: #555;
}

.turnstile-status {
    min-height: 1.35em;
    color: #334155;
}

.turnstile-noscript {
    color: #8a1c1c;
    font-weight: 600;
}

[hidden] {
    display: none !important;
}

/* Prevent mobile auto-zoom: keep inputs >= 16px */
input[type="url"],
input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 0.6rem;
    font-size: 16px;
}

button {
    align-items: center;
    background-color: #fff;
    border: 2px solid #000;
    box-sizing: border-box;
    color: #000;
    cursor: pointer;
    display: inline-flex;
    fill: #000;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    font-weight: 600;
    height: 48px;
    justify-content: center;
    letter-spacing: -0.8px;
    line-height: 24px;
    min-width: 140px;
    padding: 0 17px;
    text-align: center;
    text-decoration: none;
    transition: all .3s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* Default form submit button should be full width (mobile friendly) */
form button[type="submit"] {
    width: 100%;
    margin-top: 1rem;
}

/* Copy button should not stretch unless on mobile breakpoint */
#copy-button {
    min-width: 140px;
}

button:focus {
    color: #171e29;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 3px solid #06f;
    outline-offset: 2px;
}

button:hover {
    border-color: #06f;
    color: #06f;
    fill: #06f;
}

button:active {
    border-color: #06f;
    color: #06f;
    fill: #06f;
}

button:disabled {
    cursor: not-allowed;
    border-color: #9ca3af;
    background: #e5e7eb;
    color: #5f6875;
    fill: #5f6875;
    opacity: 1;
}

/* =========================
   Messages
========================= */
.notice {
    background: #eef5ff;
    border: 1px solid #cfe3ff;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    color: #17212b;
}

.link-preview-notice > p {
    margin: 0.55rem 0 0;
}

.link-preview-warning {
    padding: 0.7rem;
    border-left: 4px solid #b45309;
    border-radius: 4px;
    background: #fff7ed;
    color: #713f12;
}

.link-preview-data {
    display: grid;
    grid-template-columns: minmax(7rem, auto) minmax(0, 1fr);
    gap: 0.45rem 0.8rem;
    margin: 0.85rem 0 0;
}

.link-preview-data dt {
    font-weight: 700;
}

.link-preview-data dd {
    min-width: 0;
    margin: 0;
}

.link-preview-data code {
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    background: rgba(43, 56, 83, 0.08);
}

.link-preview-url,
.link-preview-url a,
.link-preview-data dd a {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.link-preview-action {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
    padding: 0.65rem 1rem;
    border: 2px solid #2b3853;
    border-radius: 6px;
    background: #2b3853;
    color: #fff;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.link-preview-action:hover {
    border-color: #06f;
    background: #06f;
    color: #fff;
}

.error {
    background: #ffecec;
    border: 1px solid #f5c2c2;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 6px;
}

.success {
    background: #e8f6ec;
    border: 1px solid #b7e0c2;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 6px;
}

.form-field + .form-field {
    margin-top: 1rem;
}

/* =========================
   Result display (short URL + copy)
========================= */
#display-result {
    margin-top: 1rem;
}

/* Key fix: input takes most space, button stays compact */
.result-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.result-row input[type="text"] {
    flex: 1 1 auto;
    min-width: 0; /* prevents overflow in flex layouts */
    height: 48px; /* match button height */
}

.result-row button {
    flex: 0 0 auto;
    height: 48px;
    margin: 0; /* avoid unexpected spacing */
    white-space: nowrap;
}

#copy-status {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* =========================
   Text blocks
========================= */
section p,
section li {
    line-height: 1.45;
}

section ul {
    padding-left: 1.25rem;
}

section ol {
    padding-left: 1.35rem;
}

h3 {
    margin: 1.25rem 0 0.35rem;
    font-size: 1rem;
}

section small {
    color: #666;
}

.service-status {
    margin: 0.75rem 0 0;
    color: #555;
    font-size: 0.95rem;
}

.footer {
    padding: 1.5rem 1rem;
    color: #cfd5e1;
    font-size: 0.9rem;
    text-align: center;
}

.footer a {
    color: inherit;
}

.footer nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 1rem;
    margin-top: 0.5rem;
}

.legal-links small {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.legal-shell {
    min-height: 100vh;
    padding: 2rem;
}

.legal-content {
    margin-bottom: 0;
}

.legal-content > :first-child {
    margin-top: 0;
}

.legal-content address {
    font-style: normal;
    line-height: 1.55;
}

.legal-content a {
    overflow-wrap: anywhere;
}

.legal-back {
    margin-bottom: 1.25rem;
}

/* =========================
   Responsive adjustments
========================= */
@media (min-width: 768px) {
    button {
        min-width: 170px;
    }
}

/* Tablets / small screens */
@media (max-width: 768px) {
    .hero {
        padding: 1.5rem;
    }

    .container,
    .content {
        padding: 1.75rem;
    }

    h1 {
        font-size: 1.4rem;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .hero {
        padding: 1rem;
    }

    .container,
    .content {
        padding: 1.25rem;
        border-radius: 6px;
    }

    h1 {
        font-size: 1.3rem;
    }

    /* Stack result row vertically on small screens */
    .result-row {
        flex-direction: column;
        align-items: stretch;
    }

    .result-row input[type="text"],
    .result-row button {
        width: 100%;
    }

    #copy-button {
        min-width: 0;
    }

    .link-type-toggle {
        grid-template-columns: 1fr;
    }

    .link-preview-data {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .link-preview-data dd + dt {
        margin-top: 0.55rem;
    }

    .legal-shell {
        padding: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
