/**
 * Base — reset, typography, global styles.
 *
 * @package CPM_Theme
 */

/* --- Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--cpm-font-family);
    font-size: var(--cpm-font-size-base);
    line-height: var(--cpm-line-height-normal);
    color: var(--cpm-text-primary);
    background-color: var(--cpm-gray-100);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img,
picture,
video,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: var(--cpm-primary);
    text-decoration: none;
    transition: color var(--cpm-transition-fast);
}

a:hover {
    color: var(--cpm-primary-dark);
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid var(--cpm-primary);
    outline-offset: 2px;
    border-radius: var(--cpm-radius-sm);
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    line-height: var(--cpm-line-height-tight);
    font-weight: 700;
    color: var(--cpm-text-primary);
}

h1 { font-size: var(--cpm-font-size-2xl); margin-bottom: var(--cpm-space-lg); }
h2 { font-size: var(--cpm-font-size-xl); margin-bottom: var(--cpm-space-md); }
h3 { font-size: var(--cpm-font-size-lg); margin-bottom: var(--cpm-space-md); }
h4 { font-size: var(--cpm-font-size-md); margin-bottom: var(--cpm-space-sm); }

p {
    margin-bottom: var(--cpm-space-md);
}

p:last-child {
    margin-bottom: 0;
}

strong, b {
    font-weight: 600;
}

small {
    font-size: var(--cpm-font-size-sm);
}

ul, ol {
    padding-left: var(--cpm-space-lg);
    margin-bottom: var(--cpm-space-md);
}

li {
    margin-bottom: var(--cpm-space-xs);
}

/* --- Forms baseline --- */
input,
textarea,
select,
button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

/* --- Utility --- */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    width: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    word-wrap: normal !important;
}

.screen-reader-text:focus {
    clip: auto !important;
    clip-path: none;
    display: block;
    font-size: var(--cpm-font-size-sm);
    font-weight: 600;
    height: auto;
    left: 5px;
    top: 5px;
    width: auto;
    z-index: 100000;
    padding: var(--cpm-space-sm) var(--cpm-space-md);
    background: var(--cpm-white);
    color: var(--cpm-primary);
    box-shadow: var(--cpm-shadow-md);
    border-radius: var(--cpm-radius-sm);
}

/* --- Selection --- */
::selection {
    background-color: var(--cpm-primary-light);
    color: var(--cpm-primary-dark);
}

/* --- Safe area insets for iOS --- */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}
