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

@layer base {
  :root {
    color-scheme: light;
  }

  * {
    @apply border-border;
  }

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

  body {
    @apply bg-ivory font-sans text-charcoal antialiased;
    font-feature-settings: "kern" 1, "liga" 1;
    text-rendering: optimizeLegibility;
  }

  html[lang="ar"] body {
    @apply font-arabic;
    letter-spacing: 0;
  }

  html[lang="ar"] h1,
  html[lang="ar"] h2,
  html[lang="ar"] h3,
  html[lang="ar"] h4,
  html[lang="ar"] .font-serif {
    font-family: var(--font-noto-arabic), var(--font-manrope), sans-serif;
    letter-spacing: 0;
  }

  h1,
  h2,
  h3,
  h4 {
    @apply font-serif font-light;
  }

  ::selection {
    background: #d8c5a5;
    color: #24221d;
  }

  :focus-visible {
    outline: 1px solid #b99a64;
    outline-offset: 3px;
  }

  input[type="number"]::-webkit-inner-spin-button,
  input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}

@layer components {
  .shell {
    @apply mx-auto w-full max-w-[1440px] px-5 md:px-10 xl:px-14;
  }

  .shell-narrow {
    @apply mx-auto w-full max-w-4xl px-5 md:px-8;
  }

  .eyebrow {
    @apply text-[12px] font-medium uppercase tracking-luxe text-gold-ink md:text-[13px];
  }

  .eyebrow-dark {
    @apply text-[12px] font-medium uppercase tracking-luxe text-walnut md:text-[13px];
  }

  .display-title {
    @apply font-serif text-4xl font-light leading-[1.05] tracking-tight md:text-6xl;
  }

  .display-title-sm {
    @apply font-serif text-3xl font-light leading-[1.1] tracking-tight md:text-5xl;
  }

  .lead {
    @apply text-[16px] leading-relaxed text-walnut md:text-[18px];
  }

  .field-label {
    @apply mb-2 block text-[12px] font-semibold uppercase tracking-[0.16em] text-walnut;
  }

  .field-error {
    @apply mt-1.5 text-[13px] text-destructive;
  }

  .hairline {
    @apply border-t border-border;
  }

  .link-underline {
    @apply relative inline-block after:absolute after:bottom-0 after:left-0 after:h-px after:w-full after:origin-left after:scale-x-100 after:bg-current after:transition-transform hover:after:origin-right hover:after:scale-x-0;
  }

  .no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .no-scrollbar::-webkit-scrollbar {
    display: none;
  }

  .rich-text {
    @apply text-[17px] leading-[1.9] text-charcoal/75;
  }
  .rich-text > * + * {
    @apply mt-5;
  }
  .rich-text h2 {
    @apply mt-10 font-serif text-2xl text-charcoal md:text-3xl;
  }
  .rich-text h3 {
    @apply mt-8 font-serif text-xl text-charcoal;
  }
  .rich-text blockquote {
    @apply border-l-2 border-gold pl-5 font-serif text-xl italic text-charcoal/80;
  }
  .rich-text ul {
    @apply list-disc space-y-2 pl-5;
  }

  .surface {
    @apply border border-line bg-cream shadow-panel;
  }

  .admin-ui table thead tr {
    background: #f6eee1;
    color: #5d5447;
  }

  .admin-ui table thead th {
    font-weight: 600;
  }

  .admin-ui table tbody tr {
    border-color: #e7ddcd;
  }

  .admin-ui table tbody tr:hover {
    background-color: #fbf7ef;
  }

  .image-zoom {
    @apply overflow-hidden;
  }
  .image-zoom img {
    @apply transition-transform duration-[1200ms] ease-out;
  }
  .image-zoom:hover img {
    @apply scale-[1.04];
  }
}

@keyframes zellige-mark-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loader-sweep {
  0% {
    transform: translateX(-150%);
  }
  100% {
    transform: translateX(450%);
  }
}

@keyframes skeleton-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@layer components {
  .zellige-mark-spin {
    transform-box: view-box;
    transform-origin: center;
    animation: zellige-mark-spin 9s linear infinite;
  }

  .loader-sweep {
    animation: loader-sweep 1.7s cubic-bezier(0.65, 0, 0.35, 1) infinite;
  }

  .skeleton-shimmer {
    position: relative;
    overflow: hidden;
    background-color: rgba(216, 197, 165, 0.22);
  }

  .skeleton-shimmer::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 253, 248, 0.72), transparent);
    animation: skeleton-shimmer 1.8s ease-in-out infinite;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zellige-mark-spin,
  .loader-sweep,
  .skeleton-shimmer::after {
    animation: none;
  }
  .skeleton-shimmer::after {
    display: none;
  }
}

@layer utilities {
  .text-balance {
    text-wrap: balance;
  }
  .text-pretty {
    text-wrap: pretty;
  }
  .writing-vertical {
    writing-mode: vertical-rl;
  }
}
