/* ========================
   Base / Reset
======================== */

@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 300 400 700 900;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  font-family: var(--font-family-base);
}

:root {
  /* Colors */
  --color-primary: #e67e22;
  --color-primary-light: rgb(228, 149, 32);
  --color-complementary: #8fcb6f;
  --color-bg: #fafafa;
  --color-surface: #fff;
  --color-text: #222;
  --color-border: #e0e0e0;
  --color-muted: #666;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;

  /* Typography */
  --font-family-base: "Vazirmatn", sans-serif;
  --font-size-base: 1rem;
  --font-size-lg: 1.2rem;
  --font-size-xlg: 1.6rem;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 600;
  --font-weight-black: 900;
}

html {
  font-size: clamp(16px, 1.2vw, 18px);
  line-height: 1.5;
  scroll-behavior: smooth;
  height: 100%;
  margin: 0;
}

body {
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  direction: rtl;
  text-align: right;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Screen reader helper */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ========================
   Layout
======================== */
header,
footer {
  background-color: var(--color-surface);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

main {
  max-width: 600px;
  margin: var(--space-lg) auto;
  padding: 0 var(--space-sm);
  flex: 1;
}

/* ========================
   Navigation
======================== */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#nav-branding {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  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 {
  text-decoration: none;
  color: #444;
  font-weight: var(--font-weight-medium);
}

nav a:hover,
nav a:focus {
  color: var(--color-primary);
}

/* ========================
   Typography
======================== */
h1 {
  font-size: var(--font-size-xlg);
  font-weight: var(--font-weight-black);
  text-align: center;
  margin-bottom: var(--space-sm);
}

h2 {
  font-weight: var(--font-weight-bold);
  margin-block: var(--space-md) var(--space-xs);
}

p {
  margin-bottom: var(--space-sm);
}

#closing-message {
  padding-top: var(--space-md);
}

/* Headings with vertical bar */
.heading-with-bar {
  position: relative;
  padding-right: 16px; /* space for the vertical bar on the right */
  font-size: 24px;
  font-weight: bold;
  line-height: 1.2;
}

.heading-with-bar::before {
  content: "";
  position: absolute;
  right: 0; /* always on the right */
  top: 25%; /* start 25% from top */
  bottom: 25%; /* end 25% from bottom */
  width: 5px; /* thickness of the line */
  background-color: var(--color-complementary);
  border-radius: 2px; /* optional rounded corners */
}

/* ========================
   Forms
======================== */
#main-content {
  margin-block-start: 3.2rem;
}

#calculator-section {
  margin-block-start: 2.8rem;
}

.greeting-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.greeting-header h1 {
  margin: 0;
  font-size: var(--font-size-xlg);
  font-weight: var(--font-weight-black);
}

#more-apps {
  font-size: 1rem;
  color: var(--color-muted);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
}

#more-apps:hover,
#more-apps:focus {
  color: var(--color-complementary);
  text-decoration: underline;
}

form {
  margin-block-start: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

label {
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-base);
  color: var(--color-text);
}

.form-label-muted {
  color: var(--color-muted);
  display: inline-block;
  margin-block-end: var(--space-xs);
}

input[type="number"] {
  min-height: 50px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: var(--font-size-base);
}

input[type="number"]:focus {
  outline: 2px solid var(--color-primary);
  border-color: var(--color-primary);
}

.form-actions {
  display: flex;
  gap: var(--space-sm);
}

button {
  flex: 1;
  min-height: 45px;
  border: none;
  border-radius: 8px;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#calculate-button {
  background-color: var(--color-primary);
  color: #fff;
}

#calculate-button:hover,
#calculate-button:focus {
  background-color: var(--color-primary-light);
}

#reset-button {
  background-color: #f2f2f2;
  color: #444;
}

#reset-button:hover,
#reset-button:focus {
  background-color: #e0e0e0;
}

/* ========================
   Results Section
======================== */
.results {
  margin-block-start: var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-sm);
  background-color: var(--color-surface);
}

.results dt {
  font-weight: var(--font-weight-bold);
  margin-block-start: var(--space-xs);
}

.results dd {
  margin: 0 0 var(--space-xs) 0;
  font-size: var(--font-size-lg);
  color: var(--color-primary);
}

/* ========================
   Footer
======================== */
footer {
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-muted);
  padding: var(--space-sm);
  border-top: 1px solid var(--color-border);
  background-color: var(--color-bg);
}

footer address {
  margin-block-start: var(--space-xs);
}

footer a {
  text-decoration: none;
  color: var(--color-primary);
}

footer a:hover,
footer a:focus {
  text-decoration: underline;
}

/* ========================
   Accessibility
======================== */
a:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ========================
   Responsive
======================== */
@media (max-width: 600px) {
  nav ul {
    gap: var(--space-xs);
  }

  .form-actions {
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
