/* ========================
   Base
======================== */

@font-face {
  font-family: "Ravi";
  src: url("/fonts/Ravi-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Ravi";
  src: url("/fonts/Ravi-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --color-primary: #e67e22;
  --color-primary-light: #e49520;
  --color-complementary: #8fcb6f;
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #222222;
  --color-muted: #666666;
  --color-border: #e0e0e0;

  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;

  --font-family-base: "Ravi", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: clamp(16px, 1.2vw, 18px);
  line-height: 1.6;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  direction: rtl;
  text-align: right;
  font-family: var(--font-family-base);
}

button,
textarea {
  font: inherit;
}

img,
svg,
canvas {
  max-width: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================
   Layout
======================== */

header {
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

main {
  width: 100%;
  max-width: 600px;
  margin: var(--space-lg) auto;
  padding: 0 var(--space-sm);
  flex: 1;
}

section + section {
  margin-block-start: 2.8rem;
}

footer {
  padding: var(--space-sm);
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
}

/* ========================
   Navigation
======================== */

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#nav-branding {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

#datakar-logo {
  height: 2rem;
  width: auto;
}

nav ul {
  list-style: none;
  display: flex;
  gap: var(--space-md);
  margin: 0;
  padding: 0;
}

nav a {
  color: #444;
  text-decoration: none;
}

nav a:hover,
nav a:focus-visible {
  color: var(--color-primary);
}

/* ========================
   Typography
======================== */

.greeting-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-sm);
}

.greeting-header h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.35;
}

#more-apps {
  flex: 0 0 auto;
  color: var(--color-muted);
  text-decoration: none;
}

#more-apps:hover,
#more-apps:focus-visible {
  color: var(--color-complementary);
  text-decoration: underline;
}

h2 {
  margin: 0 0 var(--space-sm);
}

p {
  margin: 0 0 var(--space-sm);
}

.heading-with-bar {
  position: relative;
  padding-right: 16px;
  font-size: 1.35rem;
  line-height: 1.4;
}

.heading-with-bar::before {
  content: "";
  position: absolute;
  right: 0;
  top: 25%;
  bottom: 25%;
  width: 5px;
  background: var(--color-complementary);
  border-radius: 2px;
}

/* ========================
   Form
======================== */

form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.form-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.form-label-muted {
  display: inline-block;
  margin-block-end: var(--space-xs);
  color: var(--color-muted);
}

textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
}

textarea:focus {
  border-color: var(--color-primary);
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

textarea[aria-invalid="true"] {
  border-color: #b42318;
  outline-color: #b42318;
}

.field-help {
  margin: 0.5rem 0 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.form-actions,
.download-actions {
  display: flex;
  gap: var(--space-sm);
}

button {
  flex: 1;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

#generate-button {
  background: var(--color-primary);
  color: #fff;
}

#generate-button:hover,
#generate-button:focus-visible {
  background: var(--color-primary-light);
}

#reset-button,
#download-png,
#download-svg {
  background: #f2f2f2;
  color: #444;
}

#reset-button:hover,
#reset-button:focus-visible,
#download-png:hover:not(:disabled),
#download-png:focus-visible:not(:disabled),
#download-svg:hover:not(:disabled),
#download-svg:focus-visible:not(:disabled) {
  background: #e0e0e0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ========================
   QR Result
======================== */

.qr-result {
  width: 100%;
  min-width: 0;
  padding: var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  overflow: hidden;
}

.qr-preview {
  width: 100%;
  min-width: 0;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.qr-preview canvas,
.qr-preview svg {
  display: block;
  width: min(260px, 100%);
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  flex: 0 0 auto;
}

#qr-placeholder {
  margin: 0;
  color: var(--color-muted);
  text-align: center;
}

.download-actions {
  margin-block-start: var(--space-sm);
}

#closing-note {
  color: var(--color-muted);
}

/* ========================
   Accessibility
======================== */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ========================
   Responsive
======================== */

@media (max-width: 600px) {
  html {
    font-size: 17px;
    line-height: 1.7;
  }

  header {
    padding: 0.85rem 1rem;
  }

  nav {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  nav ul {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
  }

  nav ul a {
    display: block;
    padding: 0.45rem 0.2rem;
    text-align: center;
    font-size: 0.9rem;
  }

  #datakar-logo {
    height: 2.15rem;
  }

  main {
    max-width: none;
    margin: 1.25rem auto 1.75rem;
    padding-inline: 1rem;
  }

  section + section {
    margin-block-start: 2rem;
  }

  .greeting-header h1 {
    font-size: 1.55rem;
  }

  textarea {
    min-height: 150px;
    font-size: 1rem;
  }

  .form-actions,
  .download-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  button {
    width: 100%;
    min-height: 52px;
  }

  .qr-preview {
    min-height: 250px;
    padding: 0.75rem;
  }

  .qr-preview canvas,
  .qr-preview svg {
    width: min(240px, 100%);
    height: auto;
    aspect-ratio: 1 / 1;
  }
}


/* ========================
   Language section
======================== */

#language-section {
  margin-block-start: 2.8rem;
  padding-block-start: var(--space-sm);
  border-top: 1px solid var(--color-border);
  scroll-margin-top: 1rem;
}

.language-section-inner {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--color-muted);
}

.language-label {
  font-weight: 700;
  color: var(--color-text);
}

.language-options {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.language-button {
  min-height: auto;
  width: auto;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  font-weight: 400;
  cursor: pointer;
}

.language-button:hover,
.language-button:focus-visible,
.language-button.active {
  color: var(--color-primary);
}

.language-button.active {
  font-weight: 700;
}

.language-button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.language-hint-link {
  color: var(--color-primary);
  text-decoration: none;
}

.language-hint-link:hover,
.language-hint-link:focus-visible {
  text-decoration: underline;
}

@media (max-width: 600px) {
  #language-section {
    margin-block-start: 2rem;
  }
}


/* Keep generated QR output strictly square */
#qr-preview > canvas,
#qr-preview > svg {
  aspect-ratio: 1 / 1 !important;
  width: min(260px, 100%) !important;
  height: auto !important;
  max-height: 260px;
}

@media (max-width: 600px) {
  #qr-preview > canvas,
  #qr-preview > svg {
    width: min(240px, 100%) !important;
    max-height: 240px;
  }
}
