/**
 * Base Styles
 * 
 * Core resets, custom properties, and foundational styles
 */

/* ==========================================================================
   Custom Properties
   ========================================================================== */
:root {
    /* Colors - defined in color-scheme-teal.css */
    /* Using CSS variable fallbacks for compatibility */
    --primary-color: var(--color-primary, #00867b);
    --primary-dark: var(--color-primary-dark, #005952);
    --primary-light: var(--color-primary-light, #5eb3aa);
    --text-color: var(--color-text-primary, #212121);
    --text-light: var(--color-text-secondary, #616161);
    --bg-color: var(--color-bg-primary, #ffffff);
    --bg-light: var(--color-bg-secondary, #f5f5f5);
    --border-color: var(--color-border, #e0e0e0);
    --success-color: var(--color-success, #27ae60);
    --error-color: var(--color-error, #e74c3c);
    --warning-color: var(--color-warning, #f39c12);
    --info-color: var(--color-info, #3498db);
    
    /* Typography */
    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
    --font-heading: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-base: 16px;
    --line-height-base: 1.6;
    --line-height-heading: 1.3;
    
    /* Layout */
    --container-width: 1200px;
    --container-padding: 20px;
    --header-height: 80px;
    --header-height-mobile: 60px;
    
    /* Spacing Scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 500ms ease;
    
    /* Shadows - defined in color-scheme-teal.css */
    --shadow-sm: var(--shadow-sm, 0 2px 4px rgba(0, 0, 0, 0.1));
    --shadow-md: var(--shadow-md, 0 4px 8px rgba(0, 0, 0, 0.1));
    --shadow-lg: var(--shadow-lg, 0 8px 16px rgba(0, 0, 0, 0.1));
    --shadow-xl: var(--shadow-xl, 0 12px 24px rgba(0, 0, 0, 0.1));
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-full: 9999px;
    
    /* Z-index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* ==========================================================================
   Reset & Box Model
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   Document
   ========================================================================== */
html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -moz-tab-size: 4;
    tab-size: 4;
}

/* Prevent horizontal scroll */
html,
body {
    overflow-x: hidden;
}

body {
    font-family: var(--font-primary);
    font-size: 1rem;
    line-height: var(--line-height-base);
    color: var(--text-color);
    background-color: var(--bg-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    position: relative;
    min-height: 100vh;
}

/* ==========================================================================
   Typography Base
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: var(--line-height-heading);
    color: var(--text-color);
    margin-top: 0;
    margin-bottom: var(--space-md);
}

h1 {
    font-size: clamp(2rem, 4vw, 3rem);
}

h2 {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
}

h3 {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
}

h4 {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
}

h5 {
    font-size: clamp(1.125rem, 1.5vw, 1.25rem);
}

h6 {
    font-size: 1rem;
}

p {
    margin-top: 0;
    margin-bottom: var(--space-lg);
}

/* ==========================================================================
   Links
   ========================================================================== */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--primary-dark);
}

a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ==========================================================================
   Lists
   ========================================================================== */
ul,
ol {
    margin-top: 0;
    margin-bottom: var(--space-lg);
    padding-left: var(--space-xl);
}

ul ul,
ul ol,
ol ul,
ol ol {
    margin-bottom: 0;
}

/* ==========================================================================
   Media
   ========================================================================== */
img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

img {
    border-style: none;
}

/* ==========================================================================
   Forms
   ========================================================================== */
button,
input,
optgroup,
select,
textarea {
    font-family: inherit;
    font-size: 100%;
    line-height: inherit;
    margin: 0;
}

button,
[role="button"] {
    cursor: pointer;
}

button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ==========================================================================
   Tables
   ========================================================================== */
table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
}

/* ==========================================================================
   Interactive Elements
   ========================================================================== */
details {
    display: block;
}

summary {
    display: list-item;
    cursor: pointer;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */
[hidden] {
    display: none;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: var(--space-sm) var(--space-md);
    text-decoration: none;
    border-radius: var(--radius-md);
    z-index: var(--z-tooltip);
}

.skip-link:focus {
    top: var(--space-sm);
}

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

/* ==========================================================================
   Container
   ========================================================================== */
.container {
    width: 100%;
    max-width: var(--container-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
}

/* ==========================================================================
   Content Flow
   ========================================================================== */
.content > * + * {
    margin-top: var(--space-lg);
}

/* ==========================================================================
   Responsive Typography
   ========================================================================== */
@media (max-width: 768px) {
    :root {
        --font-size-base: 14px;
    }
    
    p {
        margin-bottom: var(--space-md);
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    *,
    *::before,
    *::after {
        background: transparent;
        color: #000;
        box-shadow: none;
        text-shadow: none;
    }
    
    a,
    a:visited {
        text-decoration: underline;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
    }
    
    abbr[title]::after {
        content: " (" attr(title) ")";
    }
    
    a[href^="#"]::after,
    a[href^="javascript:"]::after {
        content: "";
    }
    
    pre {
        white-space: pre-wrap;
    }
    
    pre,
    blockquote {
        border: 1px solid #999;
        page-break-inside: avoid;
    }
    
    thead {
        display: table-header-group;
    }
    
    tr,
    img {
        page-break-inside: avoid;
    }
    
    p,
    h2,
    h3 {
        orphans: 3;
        widows: 3;
    }
    
    h2,
    h3 {
        page-break-after: avoid;
    }
}