/* --- 1. MODERN RESET & SETUP --- */
/* Defines the card as a container for intelligent resizing */
#company-result {
  container-type: inline-size;
  container-name: card;
  width: 100%;
  max-width: 650px; /* Slightly wider to let the grid breathe */
  margin-block-start: 60px; /* Logical property for top-margin */
  position: relative;
  z-index: 1;
}

/* --- 2. OKLCH COLOR PALETTE --- */
:root {
  /* Brand Colors converted to OKLCH for better rendering.
     Zanah: #e2eed9 -> Light Green
     Pizzaz: #f29600 -> Orange
     Cruose: #004519 -> Dark Green
  */
  --color-zanah: oklch(91.6% 0.086 134.7);
  --color-pizzaz: oklch(73.5% 0.175 64.7);
  --color-cruose: oklch(32.8% 0.106 148.6);
  --color-white: oklch(100% 0 0);
  --color-black: oklch(0% 0 0);

  /* ACCESSIBILITY FIX:
     The orange is too light for text. We create a derived color
     that keeps the Hue (h) but lowers Lightness (l) for contrast.
  */
  --color-pizzaz-text: oklch(55% 0.175 64.7);

  /* Semantic Variables */
  --bg-page: var(--color-zanah);
  --bg-card: var(--color-white);
  --text-main: var(--color-cruose);
  --text-body: oklch(20% 0 0); /* Soft black */
  --shadow-color: oklch(32.8% 0.106 148.6 / 10%); /* Cruose with transparency */
}

/* --- 3. PAGE LAYOUT --- */
body {
  font-family: "Josefin Sans", system-ui, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-body);
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;

  /* Improve font rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- 4. COMPONENT: COMPANY CARD --- */
.company-card {
  background-color: var(--bg-card);
  border-radius: 24px;
  padding: 40px;

  /* Modern composite shadow for depth */
  box-shadow:
    0 4px 6px -1px var(--shadow-color),
    0 10px 15px -3px var(--shadow-color),
    0 0 0 2px var(--color-white) inset; /* Inner white border ring */

  border: 1px solid color-mix(in oklch, var(--color-zanah), white 50%);

  /* GRID LAYOUT: Named Areas for clarity */
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "logo title"
    "desc desc"
    "details details";
  gap: 0 32px;
  align-items: center;
  text-align: left;

  /* Animation on entry */
  opacity: 0;
  animation: fade-up 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* --- 5. TYPOGRAPHY & ELEMENTS --- */

/* Logo Area */
.company-logo {
  grid-area: logo;
  width: 80px;
  height: 80px;
  object-fit: contain;
  /* Prevent layout shift if image is slow */
  background-color: oklch(98% 0 0);
  border-radius: 12px;
}

/* Header */
.company-card h2 {
  grid-area: title;
  font-weight: 700;
  /* Fluid Typography: Scales smoothly between 32px and 42px */
  font-size: clamp(2rem, 5cqw, 2.625rem);
  color: var(--text-main);
  margin: 0;
  line-height: 1.1;
  text-wrap: balance; /* Prevents orphaned words on new lines */
}

/* Description */
.company-description {
  grid-area: desc;
  font-weight: 300;
  font-size: 1.125rem;
  line-height: 1.6;
  margin-block-start: 24px;
  margin-block-end: 32px;
  color: var(--text-body);
  max-width: 60ch; /* Optimal reading length */
}

/* Details Grid */
.company-details {
  grid-area: details;
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 Equal columns */
  gap: 24px;
  border-top: 2px solid var(--color-zanah);
  padding-block-start: 24px;
}

.detail-item {
  display: flex;
  flex-direction: column;
}

/* Labels */
.detail-item strong {
  font-weight: 600;
  font-size: 0.875rem;
  /* Using the ACCESSIBLE orange variant */
  color: var(--color-pizzaz-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* Values */
.detail-item {
  font-weight: 300;
  font-size: 1.25rem;
  color: var(--text-main);
}

/* Interactive Links */
.detail-item a {
  color: var(--text-main);
  text-decoration: none;
  border-bottom: 2px solid var(--color-pizzaz);
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
  width: fit-content;

  /* Better focus ring for keyboard users */
  border-radius: 2px;
}

.detail-item a:hover {
  background-color: var(--color-pizzaz);
  color: var(--color-white);
}

.detail-item a:focus-visible {
  outline: 2px solid var(--color-pizzaz);
  outline-offset: 4px;
}

/* --- 6. STATES (Loading / Error) --- */
#company-result > p {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-main);
  margin-top: 80px;
  animation: pulse 2s infinite ease-in-out;
}

.error {
  background-color: oklch(97% 0.02 14); /* Very light red */
  border: 1px solid oklch(85% 0.15 20); /* Red border */
  border-radius: 16px;
  padding: 30px;
  text-align: center;
}

.error h3 {
  color: oklch(45% 0.2 20); /* Dark Red */
  font-size: 1.5rem;
  margin-top: 0;
}

/* --- 7. ANIMATIONS --- */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* --- 8. RESPONSIVENESS (Container Queries) --- */
/* When the card container is smaller than 450px, switch layout */
@container card (max-width: 450px) {
  .company-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "logo"
      "title"
      "desc"
      "details";
    text-align: center;
    gap: 16px;
  }

  .company-logo {
    justify-self: center; /* Center the logo horizontally */
  }

  .company-details {
    grid-template-columns: 1fr; /* Stack details vertically */
    text-align: left; /* Keep details readable even in centered card */
  }
}

/* Accessibility: Turn off animations if user requests */
@media (prefers-reduced-motion: reduce) {
  .company-card,
  #company-result > p {
    animation: none;
    transition: none;
  }
}
