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

@layer components {
  label {
    @apply select-none;
  }

  .form-label {
    @apply block text-ds-small font-medium pl-1 text-ink-600;
  }

  /* Fields: white on the sand surfaces, 1px rule, 6px corners, no shadow.
     Inter 15px (small), 40px tall, so they sit quietly under their labels. */
  .form-input {
    @apply mt-1 block w-full h-10 rounded-card border-rule-light bg-white px-3 py-2 text-ds-small text-ink-900 placeholder:text-ink-500 shadow-none hover:border-[#c4c1b9] focus:border-brand-green-600 focus:ring-1 focus:ring-brand-green-600;
  }

  /* Smaller pill for actions inside list rows, such as "Vis profil". */
  .form-simple-button.button-compact {
    @apply px-4 py-2 text-ds-caption;
  }

  /* Smaller field for controls inside dense rows, such as a list's status. */
  .form-input.form-input-compact {
    @apply mt-0 h-9 py-1.5 text-ds-caption;
  }

  textarea.form-input,
  select.form-input[multiple] {
    @apply h-auto;
  }

  /* A thin chevron in faint ink instead of the forms plugin's grey arrow. */
  select.form-input {
    @apply pr-9 cursor-pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%235f6668' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
  }

  /* Buttons follow the design system: pill, 16px by 24px, Inter 500 at 15px,
     no border, no shadow. */
  .form-simple-button {
    @apply select-none inline-flex justify-center items-center rounded-full px-6 py-3 text-ds-small font-medium leading-none bg-brand-green-100 text-brand-green-900 hover:bg-brand-green-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-brand-green-600 disabled:opacity-60;
  }

  .form-primary-button {
    @apply inline-flex justify-center items-center rounded-full px-6 py-3 text-ds-small font-medium leading-none text-sand-200 bg-brand-green-900 hover:bg-brand-green-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-brand-green-600 disabled:opacity-60;
  }

  /* The single most important action on a page. Use at most once. */
  .ds-accent-button {
    @apply inline-flex justify-center items-center rounded-full px-6 py-3 text-ds-small font-medium leading-none text-brand-green-900 bg-brand-green-300 hover:bg-brand-green-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-brand-green-600;
  }

  /* Card: 6px corners, no border, no shadow, a lighter surface. */
  .ds-card {
    @apply bg-sand-50 rounded-card;
  }

  /* Work mode (admin tools used for hours at a time): white cards on a bright
     background for clear edges, with a hairline so panels never blur together. */
  .work-mode .ds-card {
    @apply bg-white;
    box-shadow: 0 0 0 1px rgb(21 25 26 / 0.05);
  }

  /* Long-form reading (opportunity ads): the design system's article text.
     17px Inter at 1.65 in dark ink, about 70 characters a line, serif headings,
     a serif lede, teal bullets, and even gaps whatever the editor produced. */
  .ds-article .trix-content {
    @apply mx-auto max-w-[36rem] font-sans text-ds-body-l text-ink-900;
  }
  .ds-article .trix-content > div,
  .ds-article .trix-content > p {
    @apply mb-4;
  }
  /* Empty spacer blocks and trailing line breaks from the editor. */
  .ds-article .trix-content > div:has(> br:only-child):not(:has(*:not(br))) { display: none; }
  .ds-article .trix-content > div > br:last-child,
  .ds-article .trix-content > div > br:has(+ br:last-child) { display: none; }
  .ds-article .trix-content h1 {
    @apply mt-0 mb-8 text-center font-serif text-ds-heading font-normal text-ink-900;
  }
  .ds-article .trix-content h2,
  .ds-article .trix-content h3 {
    @apply mt-8 mb-2 font-serif text-ds-subheading font-medium leading-tight text-brand-green-800;
  }
  /* The paragraph after the opening heading reads as a lede. */
  .ds-article .trix-content > h1 + div {
    @apply font-serif text-ds-quote text-ink-900;
  }
  .ds-article .trix-content strong { @apply font-medium text-ink-900; }
  .ds-article .trix-content a { @apply text-brand-green-600 underline decoration-1 underline-offset-2 hover:text-brand-green-800; }
  .ds-article .trix-content ul,
  .ds-article .trix-content ol {
    @apply my-4 pl-5;
  }
  .ds-article .trix-content li { @apply mb-2 pl-1; }
  .ds-article .trix-content li::marker { @apply text-brand-green-600; }
  .ds-article .trix-content figure { @apply my-6; }
  .ds-article .trix-content figure img { @apply rounded-card; }

  /* Same small caps, without the square: field labels inside cards. */
  .ds-field-label {
    @apply block font-sans text-ds-label uppercase text-brand-green-600;
  }


  /* Coral is kept for destructive actions until the design system has one. */
  .form-danger-button {
    @apply inline-flex justify-center items-center rounded-full px-6 py-3 text-ds-small font-medium leading-none text-white bg-ab-coral-1000 hover:bg-ab-coral-800 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ab-coral-500 disabled:opacity-60;
  }

  .form-danger-button-bright {
    @apply inline-flex justify-center py-2 px-4 border border-transparent shadow-sm font-medium rounded-md text-white bg-ab-coral-800 hover:bg-ab-coral-400 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-60 disabled:bg-gray-500 focus:ring-red-500;
  }

  /* Quiet destructive action: coral text in a light coral pill. */
  .form-simple-danger-button {
    @apply select-none inline-flex justify-center items-center rounded-full px-6 py-3 text-ds-small font-medium leading-none bg-ab-coral-100 text-ab-coral-1000 hover:bg-ab-coral-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ab-coral-500 disabled:opacity-60;
  }

  .page-header {
    @apply font-serif text-ds-heading font-normal text-ink-900 sm:ml-6 text-center sm:text-left;
  }

  .range-slider {
    @apply w-full h-1 rounded-full appearance-none cursor-pointer;
    background: linear-gradient(to right, #41756d 0%, #41756d var(--slider-progress, 0%), #ffffff var(--slider-progress, 0%), #ffffff 100%);
  }

  .range-slider::-webkit-slider-thumb {
    @apply appearance-none w-3.5 h-3.5 bg-brand-green-700 rounded-full cursor-pointer -mt-[5px] ring-2 ring-white;
  }

  .range-slider::-moz-range-thumb {
    @apply w-3.5 h-3.5 bg-brand-green-700 rounded-full cursor-pointer border-2 border-white;
  }

  .range-slider::-webkit-slider-runnable-track {
    @apply w-full h-1 rounded-full;
    background: transparent;
  }

  .range-slider::-moz-range-track {
    @apply w-full h-1 rounded-full;
    background: transparent;
  }

  .range-slider:focus {
    @apply outline-none;
  }

  .range-slider:focus::-webkit-slider-thumb {
    @apply ring-2 ring-ab-green-500 ring-offset-1;
  }

  .range-slider:focus::-moz-range-thumb {
    @apply ring-2 ring-ab-green-500 ring-offset-1;
  }
}
