@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
    --font-sans: "Inter var";

    /* Ivoire "papier de partition" */
    --background: 36 33% 97%;
    --foreground: 243 26% 14%;
    --card: 0 0% 100%;
    --card-foreground: 243 26% 14%;
    --popover: 0 0% 100%;
    --popover-foreground: 243 26% 14%;
    /* Encre indigo */
    --primary: 245 58% 51%;
    --primary-foreground: 40 30% 98%;
    --secondary: 35 30% 94%;
    --secondary-foreground: 243 30% 18%;
    --muted: 35 25% 94%;
    --muted-foreground: 248 10% 45%;
    --accent: 35 35% 93%;
    --accent-foreground: 243 30% 18%;
    --destructive: 347 77% 50%;
    --destructive-foreground: 40 30% 98%;
    --border: 35 15% 89%;
    --input: 35 15% 89%;
    --ring: 245 58% 55%;
    --radius: 0.5rem;

    /* Ambre "gratification" (streaks, progression) */
    --highlight: 38 92% 50%;
    --highlight-foreground: 30 90% 15%;

    --success: 161 94% 30%;
    --success-foreground: 161 94% 18%;

    --info: 221 83% 53%;
    --info-foreground: 221 92% 42%;

    --attention: 21 90% 48%;
    --attention-foreground: 21 90% 30%;
}
@layer base {
    .dark {
        --background: 245 30% 8%;
        --foreground: 252 100% 97%;
        --card: 245 33% 14%;
        --card-foreground: 252 100% 97%;
        --popover: 245 33% 14%;
        --popover-foreground: 252 100% 97%;
        --primary: 234 89% 74%;
        --primary-foreground: 245 40% 12%;
        --secondary: 245 25% 18%;
        --secondary-foreground: 252 100% 97%;
        --muted: 245 25% 18%;
        --muted-foreground: 248 21% 71%;
        --accent: 245 27% 20%;
        --accent-foreground: 252 100% 97%;
        --destructive: 351 95% 71%;
        --destructive-foreground: 347 80% 12%;
        --border: 245 25% 20%;
        --input: 245 25% 20%;
        --ring: 234 89% 74%;
        --radius: 0.5rem;

        --highlight: 43 96% 56%;
        --highlight-foreground: 26 50% 12%;

        --success: 158 64% 52%;
        --success-foreground: 158 70% 12%;

        --info: 234 89% 74%;
        --info-foreground: 234 80% 16%;

        --attention: 27 96% 61%;
        --attention-foreground: 27 90% 14%;
    }
}

@layer base {
    * {
        @apply border-border;
    }
    body {
        @apply bg-background text-foreground;
        font-feature-settings:
                "rlig" 1,
                "calt" 1;
    }

    .code-sample {
        @apply max-h-[650px] min-h-[350px] overflow-x-auto rounded-lg border bg-zinc-950 dark:bg-zinc-900;
    }

    .code-sample pre {
        @apply min-h-[350px];
    }

    .code-sample span {
        @apply bg-zinc-950;
    }
    input.error {
        @apply border-red-400;
    }

    label.error {
        @apply text-destructive;
    }

    input.error:focus-visible {
        @apply ring-destructive;
    }
}

@layer components {
    .practice-area {
        @apply bg-secondary/40;
        background-image: linear-gradient(
            180deg,
            hsl(var(--primary) / 0.05),
            hsl(var(--primary) / 0) 260px
        );
    }

    .h1 {
        @apply text-4xl font-bold tracking-tight;
    }

    .h2 {
        @apply text-2xl font-semibold tracking-tight;
    }

    .h3 {
        @apply text-lg font-bold;
    }

    .h4 {
        @apply text-base font-semibold;
    }

    .select-ghost {
        @apply
        bg-transparent
        border border-transparent
        rounded-md
        px-3 py-2
        text-sm
        text-gray-800
        hover:bg-secondary
        focus:outline-none
        focus:bg-white
        focus:border-primary
        transition;
    }

    .trix-content {
        @apply text-muted-foreground leading-relaxed max-w-full overflow-hidden;
    }

    .trix-content > *:first-child {
        @apply mt-0;
    }

    .trix-content > *:last-child {
        @apply mb-0;
    }

    .trix-content h1 {
        @apply text-2xl font-bold tracking-tight text-foreground mt-8 mb-4;
    }

    .trix-content h2 {
        @apply text-xl font-semibold tracking-tight text-foreground mt-6 mb-3;
    }

    .trix-content h3 {
        @apply text-lg font-semibold text-foreground mt-5 mb-2;
    }

    .trix-content h4 {
        @apply text-base font-semibold text-foreground mt-4 mb-2;
    }

    .trix-content p {
        @apply my-3;
    }

    .trix-content a {
        @apply text-primary underline underline-offset-4 hover:opacity-80;
    }

    .trix-content strong {
        @apply font-semibold text-foreground;
    }

    .trix-content ul {
        @apply my-3 ml-5 list-disc marker:text-muted-foreground;
    }

    .trix-content ol {
        @apply my-3 ml-5 list-decimal marker:text-muted-foreground;
    }

    .trix-content ul ul,
    .trix-content ul ol,
    .trix-content ol ul,
    .trix-content ol ol {
        @apply my-1 ml-5;
    }

    .trix-content li {
        @apply my-1 pl-1;
    }

    .trix-content blockquote {
        @apply my-4 border-l-4 border-border pl-4 italic;
    }

    .trix-content pre {
        @apply my-4 overflow-x-auto rounded-lg bg-muted p-4 text-sm leading-relaxed;
    }

    .trix-content code {
        @apply rounded bg-muted px-1.5 py-0.5 text-sm;
    }

    .trix-content pre code {
        @apply bg-transparent p-0;
    }

    .trix-content img {
        @apply max-w-full h-auto rounded-md;
    }

    .trix-content hr {
        @apply my-6 border-border;
    }

    .trix-content figure {
        @apply my-4;
    }

    .trix-content figcaption {
        @apply mt-2 text-center text-sm text-muted-foreground;
    }

    /* Article de blog — lecture longue : on remonte le contraste et l'échelle
       au-dessus de ce que .trix-content impose aux activités */
    .article-content.trix-content {
        @apply text-foreground/90 text-[1.0625rem] leading-[1.75];
    }

    .article-content h1 {
        @apply text-3xl font-bold tracking-tight mt-10 mb-4;
    }

    .article-content h2 {
        @apply text-2xl font-bold tracking-tight mt-10 mb-4;
    }

    .article-content h3 {
        @apply text-xl font-semibold tracking-tight mt-8 mb-3;
    }

    .article-content h4 {
        @apply text-lg font-semibold tracking-tight mt-6 mb-2;
    }

    .article-content blockquote {
        @apply border-l-4 border-primary/40 not-italic text-foreground/80;
    }

    trix-editor {
        @apply rounded-md border border-input px-3 py-2 focus-visible:ring-2 focus-visible:ring-ring max-w-full;
    }

    /* Le contenu du Trix editor doit se replier et non déborder horizontalement */
    trix-editor {
        overflow-wrap: break-word;
    }

    trix-editor *,
    trix-editor {
        word-break: break-word;
    }

    dialog {
        max-width: calc(100% - 1.5rem);
    }

    fieldset {
        @apply border border-border rounded-lg p-6;
    }

    legend {
        @apply text-sm font-semibold text-foreground px-2 bg-primary/5 rounded-md uppercase tracking-wider;
    }
}

input[type="range"] {
    display: inline-block;
    vertical-align: middle;
    font-size: 1em;
    font-family: Arial, sans-serif;
}

/* input[type="range"]:focus,
input[type="number"]:focus {
  box-shadow: 0 0 3px 1px #4b81dd;
  outline: none;
} */

input[type="range"] {
    -webkit-appearance: none;
    margin-right: 15px;
    min-width: 200px;
    height: 7px;
    background: #f4f4f5;
    border-radius: 5px;
    background-image: linear-gradient(#000, #000);
    background-repeat: no-repeat;
}

/* Input Thumb */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: ew-resize;
    box-shadow: 0 0 2px 0 #000;
    transition: background 0.3s ease-in-out;
}

input[type="range"]::-moz-range-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: ew-resize;
    box-shadow: 0 0 2px 0 #000;
    transition: background 0.3s ease-in-out;
}

input[type="range"]::-ms-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: ew-resize;
    box-shadow: 0 0 2px 0 #000;
    transition: background 0.3s ease-in-out;
}

/* input[type="range"]::-webkit-slider-thumb:hover {
  background: #a1a1aa;
}

input[type="range"]::-moz-range-thumb:hover {
  background: #a1a1aa;
}

input[type="range"]::-ms-thumb:hover {
  background: #a1a1aa;
} */

input[type="range"]::-moz-range-track {
    -webkit-appearance: none;
    box-shadow: none;
    border: none;
    background: transparent;
}

input[type="range"]::-ms-track {
    -webkit-appearance: none;
    box-shadow: none;
    border: none;
    background: transparent;
}

.st-accordion .st-accordion__icon:before {
    content: "▼";
    display: inline-block;
    margin-right: 5px;
    font-size: 80%;
    text-decoration: none;
    transform: rotate(-90deg);
}
.st-accordion .st-accordion__icon--opened:before {
    transform: rotate(0deg);
}

.st-accordion .st-accordion__content:not(.st-accordion__content--visible) {
    height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: all 0.2s;
}
.st-accordion .st-accordion__content.st-accordion__content--visible {
    opacity: 1;
    visibility: visible;
    overflow: hidden;
    transition: all 0.2s;
}

/* Media Library */
.media-library {
    @apply flex flex-col gap-4;
}

.media-toolbar {
    @apply flex items-center justify-between gap-3 pb-3 border-b border-border;
}

.media-toolbar-search {
    @apply relative flex-1 max-w-xs;
}

.media-toolbar-search input {
    @apply w-full pl-9 pr-3 py-2 text-sm border border-input rounded-lg bg-background focus:ring-2 focus:ring-ring focus:border-ring;
}

.media-toolbar-search svg {
    @apply absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none;
}

.media-toolbar-actions {
    @apply flex items-center gap-2;
}

.media-grid {
    @apply grid grid-cols-4 sm:grid-cols-5 md:grid-cols-6 gap-2;
}

.media-card {
    @apply relative rounded-lg overflow-hidden border-2 border-transparent bg-secondary transition-all duration-150;
    aspect-ratio: 1 / 1;
}

.media-card:hover {
    @apply border-primary/40 ring-1 ring-primary/20;
}

.media-card.selected {
    @apply border-primary ring-2 ring-primary/30;
}

.media-card > label {
    @apply block w-full h-full;
}

.media-card-thumbnail {
    @apply w-full h-full object-cover block;
}

.media-card-thumbnail-placeholder {
    @apply w-full h-full flex items-center justify-center bg-secondary text-muted-foreground;
}

.media-card-overlay {
    @apply absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent opacity-0 transition-opacity duration-150 pointer-events-none;
}

.media-card:hover .media-card-overlay {
    @apply opacity-100;
}

.media-card.selected .media-card-overlay {
    @apply opacity-100;
}

.media-card.uploading .media-card-overlay {
    @apply opacity-100;
}

.media-card.uploading .progress-ring-container {
    @apply absolute inset-0 z-10 flex items-center justify-center pointer-events-none;
}

.media-card.uploading .progress-ring {
    @apply -rotate-90;
}

.media-card.uploading .progress-ring-circle {
    transition: stroke-dashoffset 0.3s ease;
}

.media-card.uploading .progress-ring-text {
    @apply absolute text-xs font-semibold text-white;
}

.media-card.uploading .status {
    @apply text-xs text-center mt-1;
}

.media-card-filename {
    @apply absolute bottom-0 left-0 right-0 px-2 py-1.5 text-xs text-white truncate;
}

.media-card-checkbox {
    @apply absolute top-2 left-2 w-5 h-5 rounded border-2 border-white bg-black/30 backdrop-blur-sm flex items-center justify-center transition-all duration-150;
}

.media-card.selected .media-card-checkbox {
    @apply bg-primary border-primary;
}

.media-card-checkbox svg {
    @apply w-3 h-3 text-white opacity-0 transition-opacity duration-150;
}

.media-card.selected .media-card-checkbox svg {
    @apply opacity-100;
}

.media-card-dropdown {
    @apply absolute top-1 right-1 z-10 opacity-0 transition-opacity duration-150;
}

.media-card:hover .media-card-dropdown {
    @apply opacity-100;
}

/* Upload Zone */
.upload-zone {
    @apply relative border-2 border-dashed border-border rounded-lg p-8 text-center transition-all duration-200;
}

.upload-zone:hover {
    @apply border-primary/50 bg-primary/5;
}

.upload-zone.dragover {
    @apply border-primary bg-primary/10 scale-[1.01];
}

.upload-zone-icon {
    @apply mx-auto w-12 h-12 text-muted-foreground mb-3;
}

.upload-zone-text {
    @apply text-sm text-muted-foreground;
}

.upload-zone-text strong {
    @apply text-foreground font-medium;
}

.upload-zone-hint {
    @apply text-xs text-muted-foreground/70 mt-2;
}

/* Media selection footer */
.media-selection-footer {
    @apply flex items-center justify-between pt-3 border-t border-border;
}

.media-selection-count {
    @apply text-sm text-muted-foreground;
}
/* CTA des héros marketing — adaptatif clair/sombre */
.hero-cta {
    @apply bg-white text-primary hover:bg-white/90 border border-white/20 dark:border-transparent dark:bg-primary-foreground dark:text-primary dark:hover:bg-primary-foreground/90;
}

/* État vide des discussions — visible seulement si seul enfant du fil */
.comments-empty {
    @apply hidden;
}

.comments-empty:only-child {
    @apply flex;
}
