/*
    Main Stylesheet
    Project: Ceredigion - The Poets, their Poems and Places
    Created: 2025-11-04
    Description: Core custom styles for the Ceredigion project
*/

/* ========================================
   Base Styles
   ======================================== */

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-primary, 'Roboto', sans-serif);
    color: var(--text-color, #333);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Roboto font class */
.w3-roboto {
    font-family: var(--font-family-primary, 'Roboto', sans-serif);
}

/* ========================================
   Layout & Container
   ======================================== */

.w3-container {
    max-width: var(--container-max-width, 1200px);
    margin: 0 auto;
}

/* Main content wrapper */
.main-content {
    padding: var(--spacing-lg, 24px);
    background-color: var(--background-white, #ffffff);
    margin: var(--spacing-lg, 24px) 0;
    border-radius: var(--border-radius-md, 6px);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.1));
}

/* ========================================
   Typography
   ======================================== */

h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    margin-top: 0;
    font-weight: 600;
}

h1 {
    font-size: 2rem;
    margin-bottom: var(--spacing-lg, 24px);
}

h2 {
    font-size: 1.75rem;
    margin-bottom: var(--spacing-md, 16px);
}

h3 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-md, 16px);
}

p {
    margin-bottom: var(--spacing-md, 16px);
}

a {
    color: var(--primary-color, #009688);
    text-decoration: none;
    transition: color var(--transition-fast, 0.15s);
}

a:hover {
    color: var(--primary-dark, #00796b);
    text-decoration: underline;
}

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

/* ========================================
   Buttons & Interactive Elements
   ======================================== */

.button,
button {
    background-color: var(--primary-color, #009688);
    color: var(--text-inverse, #ffffff);
    border: none;
    padding: var(--spacing-sm, 8px) var(--spacing-md, 16px);
    border-radius: var(--border-radius-sm, 4px);
    cursor: pointer;
    font-size: var(--font-size-base, 1rem);
    font-family: inherit;
    transition: background-color var(--transition-fast, 0.15s),
                transform var(--transition-fast, 0.15s);
}

.button:hover,
button:hover {
    background-color: var(--primary-dark, #00796b);
    transform: translateY(-1px);
}

.button:active,
button:active {
    transform: translateY(0);
}

.button:focus,
button:focus {
    outline: 2px solid var(--primary-light, #4db6ac);
    outline-offset: 2px;
}

/* ========================================
   Forms
   ======================================== */

input[type="text"],
input[type="email"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: var(--spacing-sm, 8px) var(--spacing-md, 16px);
    border: 1px solid var(--border-color, #dddddd);
    border-radius: var(--border-radius-sm, 4px);
    font-size: var(--font-size-base, 1rem);
    font-family: inherit;
    transition: border-color var(--transition-fast, 0.15s),
                box-shadow var(--transition-fast, 0.15s);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary-color, #009688);
    box-shadow: 0 0 0 3px rgba(0, 150, 136, 0.1);
    outline: none;
}

label {
    display: block;
    margin-bottom: var(--spacing-xs, 4px);
    font-weight: 500;
    color: var(--text-color, #333);
}

/* ========================================
   Tables
   ======================================== */

table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-lg, 24px) 0;
}

th, td {
    padding: var(--spacing-sm, 8px) var(--spacing-md, 16px);
    text-align: left;
    border-bottom: 1px solid var(--border-color-light, #eeeeee);
}

th {
    background-color: var(--primary-color, #009688);
    color: var(--text-inverse, #ffffff);
    font-weight: 600;
}

tr:hover {
    background-color: var(--background-color, #f5f5f5);
}

/* ========================================
   Utility Classes
   ======================================== */

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid var(--border-color-light, #eeeeee);
    border-top-color: var(--primary-color, #009688);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Text utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-light, #666666);
}

.text-small {
    font-size: var(--font-size-sm, 0.875rem);
}

/* Spacing utilities */
.mt-1 { margin-top: var(--spacing-sm, 8px); }
.mt-2 { margin-top: var(--spacing-md, 16px); }
.mt-3 { margin-top: var(--spacing-lg, 24px); }

.mb-1 { margin-bottom: var(--spacing-sm, 8px); }
.mb-2 { margin-bottom: var(--spacing-md, 16px); }
.mb-3 { margin-bottom: var(--spacing-lg, 24px); }

/* Card component */
.card {
    background-color: var(--background-white, #ffffff);
    border-radius: var(--border-radius-md, 6px);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.1));
    padding: var(--spacing-lg, 24px);
    margin-bottom: var(--spacing-lg, 24px);
}

.card-title {
    font-size: var(--font-size-xl, 1.25rem);
    font-weight: 600;
    margin-bottom: var(--spacing-md, 16px);
    color: var(--primary-color, #009688);
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    .main-content {
        padding: var(--spacing-md, 16px);
        margin: var(--spacing-md, 16px) 0;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    table {
        font-size: var(--font-size-sm, 0.875rem);
    }

    th, td {
        padding: var(--spacing-xs, 4px) var(--spacing-sm, 8px);
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: var(--spacing-sm, 8px);
        margin: var(--spacing-sm, 8px) 0;
        border-radius: 0;
    }

    h1 {
        font-size: 1.5rem;
    }

    /* Make tables scrollable on small screens */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    body {
        background: white;
        color: black;
    }

    .main-content {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    a {
        text-decoration: underline;
    }

    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }

    .no-print,
    button,
    .button {
        display: none !important;
    }

    @page {
        margin: 2cm;
    }
}

/* ========================================
   Accessibility
   ======================================== */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary-color, #009688);
    outline-offset: 2px;
}

/* Screen reader only content */
.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;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
