/*
 * curriculum-editor / styles.css
 *
 * Styling for the standalone Quebec MEES curriculum editor. Adapted from
 * the tutorat.ai design system (mint primary, tomato accent, Fraunces +
 * DM Sans typography) — same brand language as the iOS app and marketing
 * site.
 *
 * This file is intentionally self-contained: no build step, no @imports
 * beyond Google Fonts, no framework. The layout is a CSS grid keyed to
 * the ids in index.html.
 */

/* ============================================================
   FONTS
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;1,9..144,400&family=DM+Sans:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    /* Brand */
    --color-mint:         #3DAA7E;
    --color-mint-light:   #E8F5EE;
    --color-mint-dark:    #2E8B65;
    --color-tomato:       #E84233;
    --color-tomato-pale:  #F0DDD8;
    --color-tomato-deep:  #C43125;

    /* Surfaces */
    --color-bg:           #FAFAF7;
    --color-surface:      #FFFFFF;
    --color-surface-hover:#F5F3EE;

    /* Text */
    --color-fg1:          #1A1A18;
    --color-fg2:          #555550;
    --color-fg3:          #999590;

    /* Borders */
    --color-border:       rgba(0, 0, 0, 0.06);
    --color-border-hover: rgba(0, 0, 0, 0.10);

    /* Strand palette — grouped so neighbours don't clash on the graph */
    --strand-arith:       #3DAA7E; /* mint */
    --strand-algebre:     #2E8B65; /* mint-dark */
    --strand-fonctions:   #6B5BA8; /* muted violet */
    --strand-geometrie:   #E84233; /* tomato */
    --strand-statistique: #D4A03F; /* warm gold */
    --strand-probabilite: #E07B44; /* warm orange */

    /* Spacing */
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;

    /* Radius */
    --radius-card: 12px;
    --radius-input: 8px;
    --radius-pill: 9999px;

    /* Shadow */
    --shadow-card:   0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-hover:  0 4px 10px rgba(0, 0, 0, 0.06);
    --shadow-button: 0 4px 8px rgba(61, 170, 126, 0.25);

    /* Typography */
    --font-serif: 'Fraunces', Georgia, serif;
    --font-sans:  'DM Sans', system-ui, -apple-system, sans-serif;
    --font-mono:  'DM Mono', 'Courier New', monospace;
}

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

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--color-fg1);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    overflow: hidden; /* app is single-viewport; internals scroll */
}

h1, h2, h3 {
    font-family: var(--font-serif);
    font-weight: 600;
    color: var(--color-fg1);
    line-height: 1.2;
    margin: 0;
}

.hidden {
    display: none !important;
}

kbd {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 6px;
    color: var(--color-fg2);
}

/* ============================================================
   AUTH GATE
   ============================================================ */
.gate {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-mint-light) 100%);
    z-index: 100;
    padding: var(--space-xl);
}

.gate-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border-radius: var(--radius-card);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-hover);
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.gate-card h1 {
    font-size: 28px;
    margin-bottom: var(--space-xs);
}

.gate-subtitle {
    margin: 0;
    color: var(--color-fg2);
    font-size: 14px;
    margin-bottom: var(--space-md);
}

.gate-card label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-fg2);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: var(--space-sm);
    margin-bottom: calc(var(--space-xs) * -1);
}

.gate-card input {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 15px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    background: var(--color-surface);
    color: var(--color-fg1);
    transition: border-color 0.15s ease;
}

.gate-card input:focus {
    outline: none;
    border-color: var(--color-mint);
    box-shadow: 0 0 0 3px var(--color-mint-light);
}

.gate-card .error {
    color: var(--color-tomato-deep);
    font-size: 13px;
    margin: 0;
}

/* ============================================================
   APP SHELL — CSS grid
   ============================================================ */
#app {
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 280px 1fr 360px;
    grid-template-areas:
        "toolbar toolbar toolbar"
        "left    canvas  right";
    height: 100vh;
    width: 100vw;
}

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
    grid-area: toolbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    flex: 1;
    min-width: 0;
}

.toolbar-left h1 {
    font-size: 20px;
}

.discipline-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--color-fg2);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.discipline-wrap select {
    font-family: var(--font-sans);
    font-size: 14px;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    background: var(--color-surface);
    color: var(--color-fg1);
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.toolbar-status {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    color: var(--color-fg3);
    font-size: 12px;
    font-family: var(--font-mono);
}

/* ============================================================
   BUTTONS — brand language
   ============================================================ */
button {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--color-mint);
    background: var(--color-mint);
    color: #fff;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

button:hover:not(:disabled) {
    background: var(--color-mint-dark);
    border-color: var(--color-mint-dark);
}

button:active {
    transform: scale(0.97);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.primary {
    /* default — kept for explicit callers */
}

button.ghost {
    background: transparent;
    color: var(--color-mint);
}

button.ghost:hover:not(:disabled) {
    background: var(--color-mint-light);
    color: var(--color-mint-dark);
}

button.danger {
    background: var(--color-tomato);
    border-color: var(--color-tomato);
}

button.danger:hover:not(:disabled) {
    background: var(--color-tomato-deep);
    border-color: var(--color-tomato-deep);
}

button.toggle {
    background: transparent;
    color: var(--color-fg1);
    border-color: var(--color-border-hover);
}

button.toggle:hover:not(:disabled) {
    background: var(--color-surface-hover);
    color: var(--color-fg1);
    border-color: var(--color-border-hover);
}

button.toggle.active {
    background: var(--color-mint);
    color: #fff;
    border-color: var(--color-mint);
}

/* ============================================================
   LEFT SIDEBAR — filters & legend
   ============================================================ */
.sidebar-left {
    grid-area: left;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.sidebar-left section h2 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--color-fg3);
    margin-bottom: var(--space-sm);
    font-family: var(--font-sans);
}

.filter-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.filter-list label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 8px;
    border-radius: var(--radius-input);
    cursor: pointer;
    transition: background 0.1s ease;
    font-size: 13px;
    color: var(--color-fg2);
}

.filter-list label:hover {
    background: var(--color-surface-hover);
    color: var(--color-fg1);
}

.filter-list input[type="checkbox"] {
    accent-color: var(--color-mint);
    cursor: pointer;
}

.filter-list .count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-fg3);
}

.legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.legend li {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 13px;
    color: var(--color-fg2);
}

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}
.swatch.arith       { background: var(--strand-arith); }
.swatch.algebre     { background: var(--strand-algebre); }
.swatch.fonctions   { background: var(--strand-fonctions); }
.swatch.geometrie   { background: var(--strand-geometrie); }
.swatch.statistique { background: var(--strand-statistique); }
.swatch.probabilite { background: var(--strand-probabilite); }

/* ============================================================
   CANVAS
   ============================================================ */
#cy {
    grid-area: canvas;
    position: relative;
    background: var(--color-bg);
    background-image:
        radial-gradient(circle, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    overflow: hidden;
}

/* ============================================================
   RIGHT SIDEBAR — details
   ============================================================ */
.sidebar-right {
    grid-area: right;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    overflow-y: auto;
    padding: var(--space-lg);
}

.empty-state {
    color: var(--color-fg3);
    font-size: 14px;
    text-align: center;
    padding: var(--space-xl) 0;
}

.empty-state hr {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: var(--space-lg) 0;
}

.empty-state strong {
    display: block;
    color: var(--color-fg2);
    font-weight: 600;
    text-align: left;
    margin-bottom: var(--space-sm);
}

.empty-state ul {
    list-style: none;
    margin: 0;
    padding: 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    font-size: 12px;
}

.empty-state ul li {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.details {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.details h2 {
    font-family: var(--font-serif);
    font-size: 20px;
    margin-bottom: var(--space-sm);
}

.details h3 {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--color-fg3);
    margin-top: var(--space-md);
    margin-bottom: var(--space-sm);
}

.details label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-fg2);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.details input,
.details select {
    font-family: var(--font-sans);
    font-size: 14px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    background: var(--color-surface);
    color: var(--color-fg1);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.details input:focus,
.details select:focus {
    outline: none;
    border-color: var(--color-mint);
    box-shadow: 0 0 0 3px var(--color-mint-light);
}

.details input[readonly] {
    background: var(--color-surface-hover);
    color: var(--color-fg2);
}

.form-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.prereq-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.prereq-list li {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 10px;
    background: var(--color-mint-light);
    border-radius: var(--radius-input);
    font-size: 13px;
    color: var(--color-mint-dark);
}

.prereq-list li .prereq-code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-fg2);
    margin-right: var(--space-xs);
    flex-shrink: 0;
}

.prereq-list li .prereq-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-fg1);
}

.prereq-list li button {
    font-size: 12px;
    padding: 3px 8px;
    background: transparent;
    color: var(--color-tomato-deep);
    border: 1px solid transparent;
}

.prereq-list li button:hover:not(:disabled) {
    background: var(--color-tomato-pale);
    color: var(--color-tomato-deep);
    border-color: var(--color-tomato-pale);
}

.prereq-list .empty {
    color: var(--color-fg3);
    font-size: 13px;
    padding: var(--space-sm) 0;
    font-style: italic;
}

/* ============================================================
   DIALOG — new concept
   ============================================================ */
dialog {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    padding: var(--space-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 480px;
    width: 90%;
    color: var(--color-fg1);
}

dialog::backdrop {
    background: rgba(26, 26, 24, 0.35);
    backdrop-filter: blur(2px);
}

dialog h2 {
    font-family: var(--font-serif);
    font-size: 22px;
    margin-bottom: var(--space-md);
}

dialog form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

dialog label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-fg2);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

dialog input,
dialog select {
    font-family: var(--font-sans);
    font-size: 14px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    background: var(--color-surface);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    color: var(--color-fg1);
}

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

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-fg1);
    color: var(--color-surface);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-pill);
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 50;
    max-width: 90vw;
}

.toast.error {
    background: var(--color-tomato-deep);
}

.toast.success {
    background: var(--color-mint-dark);
    box-shadow: var(--shadow-button);
}
