/* ============================================================
   MAIN — Base styles, layout, typography
   Mobile-first approach
   ============================================================ */

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

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

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-app);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition), color var(--transition);
}

/* Prevent theme-transition flash on load */
body.no-transition,
body.no-transition * {
    transition: none !important;
}

/* ---- Accessibility ---- */
.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;
}

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

/* ---- App shell ---- */
.app-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Header ---- */
.app-header {
    background: var(--bg-header);
    color: var(--color-text);
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Brand layout */
.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    color: #fff;
    flex-shrink: 0;
}

.header-text h1 {
    font-size: clamp(1.05rem, 3vw, 1.4rem);
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: -0.3px;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ---- Main container ---- */
.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 14px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

/* ---- Footer ---- */
.app-footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--color-border);
    padding: 10px 20px;
    text-align: center;
    font-size: 0.80rem;
    color: var(--color-text-muted);
    margin-top: auto;
    line-height: 1.5;
}

.app-footer a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
}

.app-footer a:hover,
.app-footer a:focus {
    text-decoration: underline;
}

.version-tag {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    opacity: 0.55;
    font-family: monospace;
}

/* ---- Headings ---- */
h1, h2, h3 {
    color: var(--color-heading);
}

/* ---- Global transitions for theme switch ---- */
.app-header,
.app-footer,
.info-panel,
.sandbox-area,
.stats-dashboard,
.history-panel,
.custom-patterns-panel,
.result-box,
textarea,
.stat-card,
.pattern-item,
.history-item {
    transition:
        background-color var(--transition),
        border-color var(--transition),
        color var(--transition),
        box-shadow var(--transition);
}

/* ---- Responsive breakpoints ---- */

/* Tablet */
@media (min-width: 600px) {
    .container { padding: 16px 20px; }
    .app-header { padding: 14px 20px; }
}

/* Desktop */
@media (min-width: 1024px) {
    .container { padding: 20px 24px; gap: 16px; }
}
