@font-face {
  font-family: "Eradah Arabic";
  src: url("./assets/fonts/IBMPlexSansArabic-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Eradah Arabic";
  src: url("./assets/fonts/IBMPlexSansArabic-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Eradah Arabic";
  src: url("./assets/fonts/IBMPlexSansArabic-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --deep: #002628;
  --deep-2: #00343a;
  --green: #00894a;
  --line: rgba(255, 255, 255, .12);
  --muted: rgba(238, 248, 242, .68);
  --panel: rgba(0, 38, 40, .76);
  font-family: "Eradah Arabic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: #00191b;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 17% 4%, rgba(0, 137, 74, .18), transparent 28rem),
    radial-gradient(circle at 84% 55%, rgba(47, 169, 224, .09), transparent 34rem),
    linear-gradient(145deg, #00343a 0%, #002628 42%, #00191b 100%);
}

button, input { font: inherit; }
button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.page-texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image:
    linear-gradient(45deg, transparent 46%, rgba(255,255,255,.035) 47%, rgba(255,255,255,.035) 53%, transparent 54%),
    linear-gradient(-45deg, transparent 46%, rgba(255,255,255,.026) 47%, rgba(255,255,255,.026) 53%, transparent 54%);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

.site-header {
  position: relative;
  z-index: 3;
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 18px;
  border-bottom: 1px solid var(--line);
}

.header-logos {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.header-eradah {
  width: 340px;
  height: 101px;
  object-fit: contain;
}

.header-national {
  width: 265px;
  height: auto;
  object-fit: contain;
}

.header-divider {
  width: 1px;
  height: 58px;
  background: linear-gradient(transparent, rgba(255,255,255,.4), transparent);
}

.workspace {
  position: relative;
  z-index: 2;
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 38px 0 46px;
  display: grid;
  grid-template-columns: minmax(360px, 470px) minmax(420px, 1fr);
  gap: 42px;
  align-items: start;
}

.control-panel,
.preview-panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(0,52,58,.82), rgba(0,27,29,.82));
  box-shadow: 0 30px 80px rgba(0,0,0,.24);
  backdrop-filter: blur(18px);
}

.control-panel {
  padding: 30px;
  border-radius: 28px;
}

.intro { margin-bottom: 28px; }
.eyebrow, .preview-kicker {
  color: #54c884;
  font-size: .88rem;
  font-weight: 600;
}

.intro h1 {
  margin: 6px 0 7px;
  font-size: clamp(1.85rem, 4vw, 2.65rem);
  line-height: 1.15;
}

.intro p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.card-picker {
  min-width: 0;
  margin: 0 0 28px;
  padding: 0;
  border: 0;
}

.card-picker legend,
.name-field label {
  margin-bottom: 12px;
  font-size: 1rem;
  font-weight: 700;
}

.card-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.card-option {
  position: relative;
  overflow: hidden;
  min-width: 0;
  padding: 5px 5px 8px;
  color: #fff;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  background: rgba(255,255,255,.045);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.card-option:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.34); }
.card-option:focus-visible { outline: 3px solid rgba(47,169,224,.65); outline-offset: 3px; }

.card-option[aria-pressed="true"] {
  border-color: var(--green);
  background: rgba(0,137,74,.15);
  box-shadow: 0 0 0 2px rgba(0,137,74,.24);
}

.card-option img {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 9px;
  background: var(--deep);
}

.card-option span {
  display: block;
  overflow: hidden;
  margin-top: 6px;
  font-size: .74rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.field-heading output {
  color: var(--muted);
  direction: ltr;
  font-size: .82rem;
  unicode-bidi: isolate;
}

.name-field input {
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 14px;
  outline: none;
  background: rgba(0,18,20,.6);
  font-size: 1.08rem;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.name-field input::placeholder { color: rgba(255,255,255,.38); }
.name-field input:focus {
  border-color: #2fa9e0;
  box-shadow: 0 0 0 4px rgba(47,169,224,.14);
}

.name-field p {
  margin: 9px 0 22px;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.6;
}

.download-button {
  width: 100%;
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(135deg, #00a359, #00894a);
  box-shadow: 0 14px 34px rgba(0,137,74,.27);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
  transition: transform .18s ease, filter .18s ease, opacity .18s ease;
}

.download-button:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.download-button:focus-visible { outline: 3px solid rgba(47,169,224,.7); outline-offset: 3px; }
.download-button:disabled { cursor: not-allowed; opacity: .38; box-shadow: none; }
.download-button svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.status-message {
  min-height: 24px;
  margin: 12px 0 -8px;
  color: #71dda0;
  font-size: .88rem;
  text-align: center;
}

.preview-panel {
  min-height: 760px;
  padding: 24px;
  border-radius: 32px;
}

.preview-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.preview-heading h2 {
  margin: 3px 0 0;
  font-size: 1.35rem;
}

.resolution {
  color: var(--muted);
  font-size: .82rem;
  direction: ltr;
}

.canvas-stage {
  position: relative;
  min-height: 660px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 30%, rgba(0,137,74,.13), transparent 50%),
    rgba(0,16,18,.62);
}

#card-canvas {
  display: block;
  width: min(100%, 372px);
  height: auto;
  border-radius: 19px;
  box-shadow: 0 28px 70px rgba(0,0,0,.48);
  opacity: 0;
  transition: opacity .2s ease;
}

#card-canvas.ready { opacity: 1; }

.canvas-loading {
  position: absolute;
  color: var(--muted);
  font-size: .95rem;
}

.site-footer {
  position: relative;
  z-index: 2;
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 30px;
  color: rgba(255,255,255,.46);
  font-size: .84rem;
  text-align: center;
}

@media (max-width: 900px) {
  .site-header { padding-top: 14px; }
  .header-logos { gap: 16px; }
  .header-eradah { width: 250px; height: 75px; }
  .header-national { width: 190px; }
  .header-divider { height: 46px; }

  .workspace {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 24px;
  }

  .preview-panel { min-height: 0; }
  .canvas-stage { min-height: auto; }
  #card-canvas { width: min(100%, 430px); }
}

@media (max-width: 560px) {
  .site-header,
  .workspace,
  .site-footer { width: min(100% - 24px, 1220px); }

  .site-header {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: 14px;
  }

  .header-logos {
    min-height: 0;
    flex-direction: column;
    gap: 5px;
  }

  .header-eradah {
    width: min(76vw, 270px);
    height: auto;
    max-height: 82px;
  }

  .header-national { width: min(46vw, 158px); }
  .header-divider {
    width: 72px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.38), transparent);
  }

  .workspace {
    gap: 16px;
    padding: 16px 0 24px;
  }

  .control-panel {
    padding: 20px 16px;
    border-radius: 20px;
  }

  .intro { margin-bottom: 20px; }
  .eyebrow, .preview-kicker { font-size: .8rem; }
  .intro h1 {
    margin-top: 5px;
    font-size: clamp(1.55rem, 8vw, 1.9rem);
  }

  .intro p {
    font-size: .91rem;
    line-height: 1.65;
  }

  .card-picker { margin-bottom: 22px; }

  .card-options {
    width: 100%;
    max-width: 100%;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding: 4px 3px 12px;
    scroll-padding-inline: 3px;
    scroll-snap-type: inline mandatory;
    scrollbar-color: rgba(255,255,255,.28) transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .card-option {
    flex: 0 0 88px;
    min-height: 194px;
    scroll-snap-align: start;
    border-radius: 13px;
  }

  .card-option span {
    min-height: 2.5em;
    display: grid;
    place-items: center;
    font-size: .72rem;
    line-height: 1.25;
    text-align: center;
    text-overflow: clip;
    white-space: normal;
  }

  .name-field input {
    min-height: 54px;
    font-size: 16px;
  }

  .name-field p { margin-bottom: 18px; }
  .download-button { min-height: 56px; }

  .preview-panel {
    padding: 14px;
    border-radius: 20px;
  }

  .preview-heading {
    align-items: center;
    gap: 10px;
    margin: 2px 2px 12px;
  }

  .preview-heading h2 { font-size: 1.12rem; }
  .resolution { font-size: .72rem; white-space: nowrap; }

  .canvas-stage {
    min-height: min(620px, 72dvh);
    padding: 12px;
    border-radius: 16px;
  }

  #card-canvas {
    width: auto;
    max-width: 100%;
    max-height: 68dvh;
    border-radius: 13px;
    box-shadow: 0 18px 46px rgba(0,0,0,.45);
  }

  .site-footer {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    font-size: .76rem;
  }
}

@media (max-width: 360px) {
  .site-header,
  .workspace,
  .site-footer { width: calc(100% - 16px); }

  .control-panel { padding-inline: 13px; }
  .card-options { gap: 8px; }
  .card-option { flex-basis: 82px; min-height: 181px; }
  .preview-panel { padding: 10px; }
  .canvas-stage { padding: 9px; }
  .resolution { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
