/* Custom Minimalist CSS Framework */

/* ========================================
   CSS Variables / Theme
   ======================================== */

:root {
    /* Light theme (default) */
    --color-bg: #fafafa;
    --color-surface: #f0f0f0;
    --color-text: #1a1a1a;
    --color-text-muted: #6b6b6b;
    --color-primary: #1a1a1a;
    --color-primary-hover: #333333;
    --color-primary-text: #fafafa;
    --color-primary-focus: rgba(26, 26, 26, 0.2);
    --color-border: #e0e0e0;
    --color-success: #10b981;
    --color-error: #ef4444;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Typography */
    --font-family: 'Lora', Georgia, 'Times New Roman', serif;
    --font-family-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --line-height: 1.6;
    --line-height-tight: 1.3;

    /* Borders */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
}

/* Dark theme - system preference */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #121212;
        --color-surface: #1e1e1e;
        --color-text: #e5e5e5;
        --color-text-muted: #9a9a9a;
        --color-primary: #e5e5e5;
        --color-primary-hover: #ffffff;
        --color-primary-text: #121212;
        --color-primary-focus: rgba(229, 229, 229, 0.25);
        --color-border: #2e2e2e;
        --color-success: #34d399;
        --color-error: #f87171;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    }
}

/* Dark theme - manual override */
[data-theme="dark"] {
    --color-bg: #121212;
    --color-surface: #1e1e1e;
    --color-text: #e5e5e5;
    --color-text-muted: #9a9a9a;
    --color-primary: #e5e5e5;
    --color-primary-hover: #ffffff;
    --color-primary-text: #121212;
    --color-primary-focus: rgba(229, 229, 229, 0.25);
    --color-border: #2e2e2e;
    --color-success: #34d399;
    --color-error: #f87171;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
}

/* Light theme - manual override */
[data-theme="light"] {
    --color-bg: #fafafa;
    --color-surface: #f0f0f0;
    --color-text: #1a1a1a;
    --color-text-muted: #6b6b6b;
    --color-primary: #1a1a1a;
    --color-primary-hover: #333333;
    --color-primary-text: #fafafa;
    --color-primary-focus: rgba(26, 26, 26, 0.2);
    --color-border: #e0e0e0;
    --color-success: #10b981;
    --color-error: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
}

/* ========================================
   Reset & Base
   ======================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

* {
    margin: 0;
}

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

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

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

h1, h2, h3, h4, h5, h6 {
    line-height: var(--line-height-tight);
    letter-spacing: -0.025em;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

h1, h2 {
    font-family: 'Cinzel', serif;
    letter-spacing: 0.02em;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

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

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

small {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

strong {
    font-weight: 600;
}

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

a:not([role="button"]):not(.oauth-btn)::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 100%;
    height: 1px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 500ms ease-out;
}

a:not([role="button"]):not(.oauth-btn):hover {
    color: var(--color-primary-hover);
}

a:not([role="button"]):not(.oauth-btn):hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

code {
    font-family: var(--font-family-mono);
    font-size: 0.875em;
    background-color: var(--color-surface);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
}

pre {
    font-family: var(--font-family-mono);
    font-size: 0.875rem;
    background-color: var(--color-surface);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin-bottom: var(--spacing-md);
}

pre code {
    background: none;
    padding: 0;
}

hgroup {
    margin-bottom: var(--spacing-lg);
}

hgroup h1, hgroup h2, hgroup h3,
hgroup h4, hgroup h5, hgroup h6 {
    margin-bottom: var(--spacing-xs);
}

hgroup p {
    color: var(--color-text-muted);
    margin-bottom: 0;
}

/* ========================================
   Layout
   ======================================== */

.container {
    width: 100%;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
}

@media (min-width: 640px) {
    .container {
        padding-left: var(--spacing-lg);
        padding-right: var(--spacing-lg);
    }
}

header {
    padding-top: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
}

main {
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-2xl);
    min-height: calc(100vh - 200px);
}

footer {
    padding-bottom: var(--spacing-xl);
}

section {
    margin-bottom: var(--spacing-2xl);
}

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

/* ========================================
   Navigation
   ======================================== */

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

nav li {
    margin-bottom: 0;
}

nav a {
    color: var(--color-text);
    font-weight: 500;
}

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

.site-name {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

nav .user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

nav .user-info img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

nav .user-info span {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* ========================================
   Buttons (Pill Style)
   ======================================== */

button,
[role="button"],
input[type="submit"],
input[type="button"],
input[type="reset"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.625rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background-color: var(--color-primary);
    color: var(--color-primary-text);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition-fast),
                box-shadow var(--transition-fast),
                transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

button:hover,
[role="button"]:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
    background-color: var(--color-primary-hover);
    color: var(--color-primary-text);
    box-shadow: var(--shadow-md);
}

button:active,
[role="button"]:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
    transform: translateY(1px);
    box-shadow: var(--shadow-sm);
}

button:focus-visible,
[role="button"]:focus-visible,
input[type="submit"]:focus-visible,
input[type="button"]:focus-visible,
input[type="reset"]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

button:disabled,
[role="button"][aria-disabled="true"],
input[type="submit"]:disabled,
input[type="button"]:disabled,
input[type="reset"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Outline button variant */
button.outline,
[role="button"].outline,
.outline[role="button"] {
    background-color: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}

button.outline:hover,
[role="button"].outline:hover,
.outline[role="button"]:hover {
    background-color: var(--color-surface);
    border-color: var(--color-text-muted);
    color: var(--color-text);
}

/* Ensure link buttons don't stretch in flex containers */
a[role="button"] {
    align-self: center;
}

/* ========================================
   Forms (Minimal Style)
   ======================================== */

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    color: var(--color-text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-bg);
    color: var(--color-text);
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-muted);
    opacity: 0.7;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-focus);
}

input:disabled,
textarea:disabled,
select:disabled {
    background-color: var(--color-surface);
    opacity: 0.7;
    cursor: not-allowed;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

legend {
    font-weight: 500;
    padding: 0 var(--spacing-sm);
}

/* Checkbox & Radio */
input[type="checkbox"],
input[type="radio"] {
    -webkit-appearance: none;
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
    cursor: pointer;
    transition: border-color var(--transition-fast),
                background-color var(--transition-fast),
                box-shadow var(--transition-fast);
    flex-shrink: 0;
}

input[type="checkbox"] {
    border-radius: var(--radius-sm);
}

input[type="radio"] {
    border-radius: 50%;
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
    border-color: var(--color-text-muted);
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-focus);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

input[type="checkbox"]:checked::after {
    content: '';
    display: block;
    width: 0.35rem;
    height: 0.65rem;
    border: solid var(--color-primary-text);
    border-width: 0 2px 2px 0;
    margin: 0.15rem auto 0;
    transform: rotate(45deg);
}

input[type="radio"]:checked::after {
    content: '';
    display: block;
    width: 0.5rem;
    height: 0.5rem;
    background-color: var(--color-primary-text);
    border-radius: 50%;
    margin: 0.3rem auto 0;
}

input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
    background-color: var(--color-surface);
    border-color: var(--color-border);
    opacity: 0.7;
    cursor: not-allowed;
}

/* Inline checkbox/radio labels */
label:has(input[type="checkbox"]),
label:has(input[type="radio"]) {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-weight: 400;
    cursor: pointer;
}

/* Form button spacing */
form button[type="submit"],
form input[type="submit"],
form [role="button"] {
    margin-top: var(--spacing-lg);
}

/* ========================================
   Articles / Cards
   ======================================== */

article {
    margin-bottom: var(--spacing-lg);
}

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

article header {
    padding: 0;
    margin-bottom: var(--spacing-md);
}

article footer {
    padding: 0;
    margin-top: var(--spacing-lg);
}

/* ========================================
   Alerts
   ======================================== */

[role="alert"] {
    background-color: var(--color-surface);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

[role="alert"]:last-child {
    margin-bottom: 0;
}

/* Flash messages */
.flash-messages {
    margin-bottom: var(--spacing-lg);
}

.flash-messages [role="alert"] {
    margin-bottom: var(--spacing-sm);
}

/* ========================================
   Horizontal Rule
   ======================================== */

hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--spacing-lg) 0;
}

/* ========================================
   Lists
   ======================================== */

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

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

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

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-md);
}

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

th {
    font-weight: 600;
    background-color: var(--color-surface);
}

/* ========================================
   Utilities
   ======================================== */

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }

/* Error page vertical centering */
.error-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 160px);
    padding-top: 0;
    padding-bottom: 0;
}

.error-page article {
    text-align: center;
    background-color: transparent;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

/* ========================================
   Admin Layout
   ======================================== */

main.container.admin-layout {
    max-width: none;
    margin-left: var(--spacing-lg);
    margin-right: var(--spacing-lg);
    padding-top: var(--spacing-lg);
}

.admin-container {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: var(--spacing-xl);
    min-height: calc(100vh - 200px);
}

@media (max-width: 768px) {
    .admin-container {
        grid-template-columns: 1fr;
    }
}

.admin-sidebar {
    border-right: 1px solid var(--color-border);
    padding-right: var(--spacing-lg);
}

@media (max-width: 768px) {
    .admin-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        padding-right: 0;
        padding-bottom: var(--spacing-lg);
    }
}

.admin-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    width: 100%;
}

.admin-nav li {
    width: 100%;
}

@media (max-width: 768px) {
    .admin-nav ul {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

.admin-nav a {
    display: block;
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    color: var(--color-text);
    transition: background-color var(--transition-fast);
}

.admin-nav a:hover {
    background-color: var(--color-surface);
}

.admin-nav a.active {
    background-color: var(--color-primary);
    color: var(--color-primary-text);
}

.admin-nav a::after {
    display: none;
}

.admin-content {
    min-width: 0;
}

/* Admin header with title and actions */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-lg);
}

.admin-header [role="button"] {
    margin-top: 0;
    flex-shrink: 0;
}

/* Admin Quick Links */
.admin-quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}

.admin-card {
    display: block;
    padding: var(--spacing-lg);
    background-color: var(--color-surface);
    border-radius: var(--radius-md);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.admin-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.admin-card::after {
    display: none;
}

.admin-card h3 {
    margin-bottom: var(--spacing-xs);
    font-size: 1.125rem;
}

.admin-card p {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin: 0;
}

/* Admin Tables */
.admin-table {
    width: 100%;
    margin-top: var(--spacing-lg);
}

.admin-table th,
.admin-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.user-cell {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background-color: var(--color-surface);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.user-info-card p {
    margin: 0;
}

/* Badges */
.role-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background-color: var(--color-surface);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: var(--spacing-xs);
}

.status-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
}

.status-published {
    background-color: var(--color-success);
    color: white;
}

.status-draft {
    background-color: var(--color-surface);
    color: var(--color-text-muted);
}

.type-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background-color: var(--color-surface);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
}

/* Small buttons */
button.small,
[role="button"].small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* Danger button variant */
button.danger,
[role="button"].danger {
    color: var(--color-error);
    border-color: var(--color-error);
}

button.danger:hover,
[role="button"].danger:hover {
    background-color: var(--color-error);
    color: white;
    border-color: var(--color-error);
}

/* Inline forms */
.inline-form {
    display: inline-block;
    margin: 0;
}

.inline-form button {
    margin-top: 0;
}

/* Actions cell */
.actions-cell {
    display: flex;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.form-actions button,
.form-actions [role="button"] {
    margin-top: 0;
}

/* No items message */
.no-items {
    text-align: center;
    color: var(--color-text-muted);
    padding: var(--spacing-xl) 0;
}
