/* ============================================
   Cardly Design System - Minimalist Green/White
   ============================================ */

:root {
    /* Primary Colors */
    --primary: #16a34a;           /* green-600 - main accent */
    --primary-light: #22c55e;     /* green-500 */
    --primary-lighter: #4ade80;   /* green-400 */
    --primary-dark: #15803d;      /* green-700 */
    --primary-bg: rgba(22, 163, 74, 0.08);
    --primary-bg-hover: rgba(22, 163, 74, 0.12);

    /* Surfaces */
    --fc-bg-panel: #ffffff;
    --fc-bg-panel-soft: #fafafa;
    --fc-border-subtle: #e5e7eb;  /* gray-200 */

    /* Legacy compatibility */
    --fc-purple: #16a34a;
    --fc-purple-soft: #15803d;

    /* Text */
    --fc-text-main: #111827;      /* gray-900 */
    --fc-text-muted: #6b7280;     /* gray-500 */
    --fc-text-light: #9ca3af;     /* gray-400 */
    --fc-error: #dc2626;          /* red-600 */

    /* Geometry */
    --fc-radius-sm: 0.5rem;
    --fc-radius-md: 0.75rem;
    --fc-radius-lg: 1rem;
    --fc-radius-panel: 1rem;
    --fc-radius-chip: 9999px;

    /* Spacing */
    --fc-gap-xs: 0.5rem;
    --fc-gap-sm: 0.75rem;
    --fc-gap-md: 1rem;
    --fc-gap-lg: 1.5rem;
    --fc-gap-xl: 2rem;

    /* Effects */
    --fc-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --fc-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --fc-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    --fc-shadow-panel: var(--fc-shadow-lg);

    /* Page-level tokens */
    --bg: #ffffff;
    --fg: #111827;
    --muted: #6b7280;
    --accent: #16a34a;
    --accent-2: #22c55e;
    --card: #ffffff;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --success: #16a34a;
    --danger: #dc2626;
}

/* Global layout, typography, and utilities */

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.6 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color-scheme: light;
}

/* Container */
.container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Top-level app header + main column */

.app-header {
    max-width: 1024px;
    margin: 0 auto;
    padding: 1.5rem;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--primary);
}

.app-header .app-tagline {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--fc-text-muted);
}

#home {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

/* ============================================
   Button System
   ============================================ */

/* Base button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--fc-radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary button - filled green */
.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Secondary button - outlined */
.btn-secondary {
    background: white;
    color: var(--fc-text-main);
    border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--fc-bg-panel-soft);
    border-color: var(--primary);
    color: var(--primary);
}

/* Ghost button - text only */
.btn-ghost {
    background: transparent;
    color: var(--fc-text-muted);
    border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--primary-bg);
    color: var(--primary);
}

/* Danger button */
.btn-danger {
    background: white;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: #fef2f2;
}

/* Button sizes */
.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-full {
    width: 100%;
}

/* Legacy button support */
.button {
    padding: 0.625rem 1.25rem;
    border-radius: var(--fc-radius-md);
    border: 1px solid var(--border-strong);
    background: white;
    color: var(--fg);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.button:hover,
.button:focus-visible {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
    outline: none;
}

.button:active {
    transform: translateY(1px);
}

.button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Horizontal rule */

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* A11y helpers */

.visually-hidden {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
    clip-path: inset(50%);
}

/* Card mirror: when focused, present as a small overlay for easy copy */

.card-mirror {
    font: inherit;
    line-height: 1.35;
    user-select: text;
}

.card-mirror:focus,
.card-mirror:focus-visible,
.card-mirror.is-focused {
    /* undo visually-hidden */
    clip: auto !important;
    clip-path: none !important;
    height: auto !important;
    width: auto !important;
    overflow: visible !important;
    white-space: pre-wrap !important;

    position: fixed !important;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    max-width: 900px;
    margin: 0 auto;

    height: 10rem;
    padding: 0.75rem 1rem;

    border: 1px solid var(--border-strong);
    border-radius: var(--fc-radius-md);
    background: white;
    box-shadow: var(--fc-shadow-md);

    z-index: 50;
    resize: none;
}

/* Respect reduced motion */

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
    .button:active,
    .btn:active {
        transform: none !important;
    }
}

/* Slightly larger padding on wider screens */

@media (min-width: 840px) {
    .container {
        padding: 2rem;
    }
}

/* Generic button group primitive */

.button-group {
    display: inline-flex;
    border-radius: var(--fc-radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

.button-group .button {
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
}

.button-group .button:last-child {
    border-right: none;
}

/* ============================================
   Card/Panel System
   ============================================ */

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--fc-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--fc-shadow-sm);
}

.card-elevated {
    box-shadow: var(--fc-shadow-md);
}

/* Shared panel shell for Decks + Cards Svelte islands */
.cards-app,
.decks-app {
    max-width: 1024px;
    margin: 1.5rem auto;
    padding: 1.5rem;
    border-radius: var(--fc-radius-lg);
    background: white;
    box-shadow: var(--fc-shadow-md);
    border: 1px solid var(--border);
}

/* Shared heading + subtitle look */
.cards-header h2,
.decks-header-row h2 {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.cards-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.cards-subtitle,
.decks-subtitle {
    margin: 0 0 var(--fc-gap-md);
    font-size: 0.875rem;
    color: var(--fc-text-muted);
}

/* ============================================
   Chip/Badge System
   ============================================ */

.fc-tag-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--fc-radius-chip);
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 500;
    margin: 0 0.35rem 0.35rem 0;
    white-space: nowrap;
}

.fc-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    border-width: 1px;
    border-style: solid;
}

/* Active / retired variants */
.fc-status-pill--active {
    color: var(--primary);
    background: var(--primary-bg);
    border-color: var(--primary-light);
}

.fc-status-pill--retired {
    color: var(--danger);
    background: #fef2f2;
    border-color: #fecaca;
}

/* ============================================
   Header Navigation (Inline - No Modal)
   ============================================ */

.fc-header {
    max-width: 1024px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--border);
}

.fc-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.fc-title {
    margin: 0;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}

.fc-header .fc-title {
    font-size: 1.25rem;
}

/* Navigation menu - inline on desktop */
.fc-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.fc-nav a {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--fc-text-muted);
    text-decoration: none;
    border-radius: var(--fc-radius-md);
    transition: all 0.15s ease;
}

.fc-nav a:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.fc-nav a[aria-current="page"] {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}

.fc-nav-signout {
    margin-left: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--fc-text-muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--fc-radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.fc-nav-signout:hover {
    background: #fef2f2;
    border-color: var(--danger);
    color: var(--danger);
}

/* Mobile menu button */
.fc-menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: white;
    color: var(--fg);
    border-radius: var(--fc-radius-md);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.fc-menu-btn:hover,
.fc-menu-btn:focus-visible {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
    outline: none;
}

/* Mobile dialog styles */
.fc-menu-dialog {
    width: min(92vw, 320px);
    padding: 0;
    margin: auto;
    border-radius: var(--fc-radius-lg);
    border: 1px solid var(--border);
    background: white;
    color: var(--fg);
    box-shadow: var(--fc-shadow-lg);
}

.fc-menu-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.fc-menu-dialog-inner {
    padding: 1rem;
}

.fc-menu-dialog .fc-title {
    font-size: 1rem;
    color: var(--primary);
}

.fc-menu {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.25rem;
}

.fc-menu a,
.fc-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border-radius: var(--fc-radius-md);
    border: none;
    background: transparent;
    color: var(--fc-text-main);
    text-decoration: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    min-height: 44px;
}

.fc-menu a:hover,
.fc-menu a:focus-visible,
.fc-menu button:hover,
.fc-menu button:focus-visible {
    background: var(--primary-bg);
    color: var(--primary);
    outline: none;
}

.fc-menu a[aria-current="page"] {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}

.fc-menu-sep {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

.fc-menu-signout {
    color: var(--danger) !important;
}

.fc-menu-signout:hover {
    background: #fef2f2 !important;
}

/* Show mobile menu on small screens */
@media (max-width: 640px) {
    .fc-nav {
        display: none;
    }
    
    .fc-menu-btn {
        display: inline-flex;
    }
    
    .fc-header {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 420px) {
    .fc-menu-dialog {
        width: calc(100vw - 1.5rem);
    }
}

/* ============================================
   Form Inputs
   ============================================ */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--fc-text-main);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    color: var(--fc-text-main);
    border: 1px solid var(--border-strong);
    border-radius: var(--fc-radius-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-input::placeholder {
    color: var(--fc-text-light);
}

.form-input:disabled {
    background: var(--fc-bg-panel-soft);
    cursor: not-allowed;
}

/* Legacy input styles */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
    background: white;
    color: var(--fc-text-main);
    border: 1px solid var(--border-strong);
    border-radius: var(--fc-radius-md);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

input[type="checkbox"] {
    accent-color: var(--primary);
    width: 1.125rem;
    height: 1.125rem;
}

/* Select inputs */
select {
    appearance: none;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E") no-repeat right 1rem center;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--fc-text-main);
    border: 1px solid var(--border-strong);
    border-radius: var(--fc-radius-md);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

/* Error message */
.form-error {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--fc-error);
}

.form-hint {
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--fc-text-muted);
}
