/* ==========================================================================
   BASE & FOUNDATIONS
   ========================================================================== */

/* --- RESET --- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* Accessible Focus Indicators */
:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 4px;
}


button:focus-visible, 
a:focus-visible, 
input:focus-visible, 
textarea:focus-visible, 
select:focus-visible, 
[role="button"]:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

body {
    font: var(--md-sys-typescale-body-large);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    transition: background-color var(--md-sys-motion-standard), color var(--md-sys-motion-standard);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
}

main {
    flex: 1;
    margin-left: 80px;
    min-width: 0; /* Prevents flex items from overflowing */
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--md-sys-color-outline-variant); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--md-sys-color-outline); }

/* --- UTILITIES --- */
.hidden { display: none !important; }
.scrolled { background-color: var(--md-sys-color-surface-container) !important; }

/* --- RIPPLE --- */
.ripple-target { position: relative; overflow: hidden; transform: translate3d(0, 0, 0); }
span.ripple {
    position: absolute; border-radius: 50%; transform: scale(0);
    animation: ripple 600ms cubic-bezier(0.4, 0, 0.2, 1);
    background-color: currentColor; opacity: 0.12; pointer-events: none;
}
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* --- LAYOUTS --- */
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.section-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr)); 
    gap: 32px; 
    align-items: start;
}
.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    grid-auto-rows: minmax(160px, auto);
    gap: 32px;
}
@media (min-width: 1200px) {
    .bento-grid { grid-template-columns: repeat(4, 1fr); }
}
.container { 
    width: min(100% - 64px, 1400px); 
    margin: 0 auto; 
    padding: 80px 0; 
}

/* --- TYPOGRAPHY --- */
h1 { font: var(--md-sys-typescale-display-medium); margin-bottom: 48px; }
h2 { font: var(--md-sys-typescale-headline-medium); margin: 64px 0 32px 0; }
h3 { font: var(--md-sys-typescale-title-large); margin: 40px 0 24px 0; }
h4 { font: var(--md-sys-typescale-title-medium); margin: 32px 0 16px 0; }
p { font: var(--md-sys-typescale-body-large); margin-bottom: 24px; line-height: 1.6; color: var(--md-sys-color-on-surface-variant); }

/* Reset margins for headings at the start of containers */
.md-card > *:first-child, .container > *:first-child { margin-top: 0 !important; }

/* --- TOP ACTION BAR --- */
.top-app-bar .actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- ICONS --- */
.material-symbols-rounded, .material-symbols-outlined {
    font-size: 24px;
}

/* --- COLOR SWATCHES (Global) --- */
.color-swatch { 
    width: 24px; height: 24px; border-radius: 50%; cursor: pointer; 
    transition: transform 200ms ease, box-shadow 200ms ease;
    border: 2px solid transparent;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { 
    border-color: var(--md-sys-color-on-surface); 
    box-shadow: 0 0 0 2px var(--md-sys-color-surface);
}

/* --- BOTTOM SHEET --- */
.bottom-sheet {
    position: fixed; bottom: 0; left: 0; right: 0;
    margin: 0 auto; width: 100%; max-width: 640px;
    background: var(--md-sys-color-surface-container);
    border-radius: 28px 28px 0 0;
    padding: 32px; z-index: 600;
    transform: translateY(100%); transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    border: 1px solid var(--md-sys-color-outline-variant);
}
.bottom-sheet.open { transform: translateY(0); }
.drag-handle { width: 32px; height: 4px; background: var(--md-sys-color-outline-variant); margin: -16px auto 24px auto; border-radius: 2px; }
.sheet-scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 599;
    opacity: 0; pointer-events: none; transition: 0.3s;
}

/* --- RESPONSIVE UTILITIES --- */
@media (max-width: 720px) {
    .desktop-only { display: none !important; }
    .mobile-only { display: flex !important; }
}
@media (min-width: 721px) {
    .desktop-only { display: flex !important; }
    .mobile-only { display: none !important; }
}

/* --- COLOR SHEET GRID --- */
.color-sheet-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    padding: 16px 8px;
}
.color-sheet-grid .color-swatch {
    width: 48px;
    height: 48px;
    margin: 0 auto;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 720px) {
    main { margin-left: 0 !important; }
    .container { width: min(100% - 24px, 1600px); }
}

@media (max-width: 600px) {
    .container { padding-top: 72px; }
    h1 { font: var(--md-sys-typescale-display-small); }
    h2 { font: var(--md-sys-typescale-headline-small); }
}
