/* ========================================
   متن · Recording Portal
   Arabic-first, RTL-native design
   ======================================== */

/* --- Custom Properties --- */
:root {
  /* Matn: ink, parchment, and restrained brass rubrication. */
  --color-bg: #f8f6f2;
  --color-bg-elevated: #fefdfb;
  --color-bg-hover: #f4f0e8;
  --color-bg-active: #ede7dc;
  --color-surface: #fbf9f4;
  --color-surface-alt: #f0ebe1;

  --color-text: #1a1714;
  --color-text-secondary: #4a433b;
  --color-text-tertiary: #6e675d;
  --color-text-inverse: #f8f6f2;

  --color-primary: #1a1714;
  --color-primary-hover: #332b25;
  --color-primary-active: #0d0b09;
  --color-primary-light: #e8dfcc;
  --color-primary-lighter: #f8f4ea;

  --color-danger: #c53030;
  --color-danger-light: #fde8e8;
  --color-success: #2e7d32;
  --color-success-light: #e4efe4;
  --color-warning: #8b6914;
  --color-warning-light: #fef3cd;

  --color-border: #c8bfb0;
  --color-border-light: #e2ddd4;

  /* Recording states */
  --color-rec: #c53030;
  --color-rec-glow: rgba(197, 48, 48, 0.3);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 6px rgba(26,23,20,0.08);
  --shadow-lg: 0 4px 8px rgba(26,23,20,0.10);
  --shadow-xl: 0 6px 12px rgba(26,23,20,0.12);

  /* Typography */
  --font-ui: 'Urbanist', 'Noto Sans Arabic', system-ui, sans-serif;
  --font-display: 'Scheherazade New', 'Traditional Arabic', serif;
  --font-poem: 'Amiri', 'Traditional Arabic', serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

[data-screen-focus]:focus {
  outline: none;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  background: var(--color-bg);
  color: var(--color-text);
  direction: rtl;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.7;
}

/* --- Screens --- */
.screen {
  display: none;
  min-height: 100dvh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* --- Loading Screen --- */
#loading-screen {
  justify-content: center;
  align-items: center;
  background: var(--color-bg);
}

.loading-content {
  text-align: center;
}

.loading-logo {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-lg);
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  margin: 0 auto var(--space-sm);
}

.loading-mark {
  margin-bottom: var(--space-sm);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--space-md);
}

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

.loading-text {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

/* --- Consent Screen --- */
#consent-screen {
  justify-content: center;
  align-items: center;
  padding: var(--space-lg);
  background: var(--color-bg);
}

.consent-container {
  width: 100%;
  max-width: 560px;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
}

.consent-header {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-2xl) var(--space-xl) var(--space-lg);
  text-align: center;
}

.consent-logo {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  opacity: 0.9;
}

.consent-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.consent-subtitle {
  font-size: 0.9rem;
  opacity: 0.85;
}

.consent-body {
  padding: var(--space-xl);
}

.consent-section {
  margin-bottom: var(--space-lg);
}

.consent-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
}

.consent-section p {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  line-height: 1.8;
}

.consent-section ul {
  list-style: none;
  padding: 0;
}

.consent-section li {
  position: relative;
  padding-right: var(--space-lg);
  margin-bottom: var(--space-sm);
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

.consent-section li::before {
  content: '';
  position: absolute;
  right: 0;
  top: 10px;
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
}

/* --- Forms --- */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

.form-group input[type="text"],
.form-group select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color var(--duration-fast) var(--ease-out);
  direction: rtl;
}

.form-group input[type="text"]::placeholder {
  color: var(--color-text-tertiary);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* --- Consent checkbox --- */
.consent-agreement {
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  background: var(--color-primary-lighter);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-primary-light);
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--color-text);
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkmark {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-primary);
  border-radius: var(--space-xs);
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
}

.checkbox-label input:checked + .checkmark {
  background: var(--color-primary);
}

.checkbox-label input:checked + .checkmark::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-ui);
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  font-size: 1rem;
}

.btn-primary:not(:disabled):hover {
  background: var(--color-primary-hover);
}

.btn-primary:not(:disabled):active {
  background: var(--color-primary-active);
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  border: 1.5px solid var(--color-border);
}

.btn-secondary:not(:disabled):hover {
  background: var(--color-bg-hover);
  border-color: var(--color-text-tertiary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
}

.btn-ghost:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.btn-large {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.auth-assurance {
  margin: var(--space-md) 0 var(--space-xs);
  color: var(--color-text-tertiary);
  font-size: 0.8rem;
  line-height: 1.65;
  text-align: center;
}

/* --- App Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border-light);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-sm) var(--space-md);
  min-height: 56px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo {
  font-family: var(--font-poem);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary);
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
}

.header-title {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.session-badge {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--color-success-light);
  color: var(--color-success);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.session-icon {
  font-size: 0.85rem;
}

/* --- Poem List --- */
.list-content {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-3xl);
  width: 100%;
}

.progress-section {
  margin-bottom: var(--space-xl);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.progress-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.progress-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary);
}

.progress-bar {
  height: 8px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
}
