/* Reset, typography and shared controls. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

p {
    margin: 0;
}

[hidden] {
    display: none !important;
}

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

.icon {
    flex-shrink: 0;
}

/* Fields */
input[type="text"],
input[type="search"] {
    appearance: none;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    transition: border-color var(--ease), box-shadow var(--ease);
}

input:focus {
    outline: none;
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

input::placeholder {
    color: var(--text-tertiary);
}

/* Buttons: neutral by default, .btn--primary / .btn--ghost / .btn--icon modifiers */
button,
.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}

button:hover,
.btn:hover {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
}

button:active,
.btn:active {
    transform: translateY(1px);
}

button:focus-visible,
.btn:focus-visible,
a:focus-visible,
select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
}

.btn--primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.btn--primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn--ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--text-secondary);
}

.btn--ghost:hover {
    background: var(--bg-hover);
    border-color: transparent;
    color: var(--text-primary);
}

.btn--icon {
    width: 32px;
    height: 32px;
    padding: 0;
}

/* Copy buttons swap their icon to a check while .is-copied */
.copy-toggle .icon--check,
.copy-toggle.is-copied .icon--copy {
    display: none;
}

.copy-toggle.is-copied .icon--check {
    display: inline;
    color: var(--accent-success);
}

.copy-feedback {
    min-height: 18px;
    font-size: 12px;
    color: var(--accent-success);
}

.copy-feedback--error {
    color: var(--accent-error);
}

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

/* Touch screens: 44px tap targets (Apple HIG, WCAG 2.5.5) and 16px fields,
   below which iOS Safari zooms the page on focus. */
@media (pointer: coarse) {
    input[type="text"],
    input[type="search"] {
        min-height: 44px;
        font-size: 16px;
    }

    button,
    .btn {
        min-height: 44px;
    }

    .btn--icon {
        min-width: 44px;
    }
}
