/* ================================
   Masri Lernkarten — Responsive Design
   Optimiert für: Handy, Tablet, PC
   Version 2.0
================================ */

:root {
  --bg: #f6fbf6;
  --card-bg: rgba(255,255,255,0.95);
  --accent: #2f8b46;
  --accent-dark: #247035;
  --muted: #7a7a7a;
  --max-width: 1200px;

  --flag-blue: #3b82f6;
  --flag-green: #16a34a;
  --flag-red: #ef4444;

  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,0.1);

  font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: #222;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 16px;
  width: 100%;
}

/* ============================================================
   TOP BAR - Responsive Header
============================================================ */

.topbar {
  background: linear-gradient(180deg, #2f8b46, #4aa76a);
  color: white;
  padding: 16px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(20px, 5vw, 28px);
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.topbar .container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.controls-row label {
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  white-space: nowrap;
}

/* ============================================================
   BUTTONS
============================================================ */

.btn {
  background: #fff;
  border: 0;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn.accent {
  background: var(--accent);
  color: #fff;
}

.btn.accent:hover {
  background: var(--accent-dark);
}

/* ============================================================
   PAGE / MAIN CONTENT
============================================================ */

.page {
  padding: 16px;
  flex: 1;
  background-image: url('./images/nature_mix.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  position: relative;
}

/* ============================================================
   SELECT / DROPDOWN
============================================================ */

select {
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid rgba(0,0,0,0.1);
  min-width: 140px;
  max-width: 100%;
  background: white;
  font-size: 14px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ============================================================
   PANEL (Karten-Auswahl)
============================================================ */

.panel {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  padding: 14px 18px;
  border-radius: 12px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.panel label {
  color: rgba(255,255,255,0.95);
  font-size: 14px;
  font-weight: 500;
}

.panel select {
  flex: 1;
  min-width: 200px;
}

/* ============================================================
   CARD CONTAINER
============================================================ */

.card-wrap {
  display: flex;
  justify-content: center;
  padding: 10px;
}

.card {
  width: 100%;
  max-width: 800px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  border-left: 6px solid rgba(200,200,200,0.5);
  box-shadow: var(--shadow);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  position: relative;
  overflow: hidden;
}

/* FLAGS */
.card.flagged { border-left-color: var(--flag-blue); }
.card.known { border-left-color: var(--flag-green); }
.card.unknown { border-left-color: var(--flag-red); }

/* ============================================================
   CARD META
============================================================ */

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.category-with-edit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-category {
  font-weight: 700;
  color: var(--accent);
  font-size: 14px;
  background: rgba(47,139,70,0.1);
  padding: 4px 12px;
  border-radius: 20px;
}

/* Skarabäus-Button neben Kategorie */
.scarab-btn-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd700, #ffb347);
  border: 2px solid rgba(255,255,255,0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  opacity: 0.85;
}

.scarab-btn-small:hover {
  transform: scale(1.15);
  opacity: 1;
  box-shadow: 0 3px 12px rgba(0,0,0,0.25);
}

.scarab-btn-small:active {
  transform: scale(0.95);
}

.scarab-symbol {
  font-size: 16px;
  line-height: 1;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.card-id {
  color: var(--muted);
  font-size: 14px;
}

/* ============================================================
   CARD TEXTS
============================================================ */

.card-de {
  font-size: clamp(22px, 5vw, 32px);
  margin: 10px 0;
  color: #113;
  font-weight: 600;
  line-height: 1.3;
}

.card-u {
  font-size: clamp(16px, 3.5vw, 20px);
  color: #2b2b2b;
  font-style: italic;
  margin-bottom: 10px;
}

.card-ar {
  font-size: clamp(20px, 4.5vw, 28px);
  color: #083;
  direction: rtl;
  text-align: right;
  margin-top: 10px;
  font-family: "Amiri", "Traditional Arabic", serif;
  line-height: 1.6;
}

/* ============================================================
   AUDIO SECTION
============================================================ */

.audio-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.audio-row audio {
  width: 100%;
  border-radius: 8px;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.audio-controls label {
  font-size: 13px;
  color: var(--muted);
}

input[type=range] {
  width: 100px;
  cursor: pointer;
}

.speed-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 13px;
}

/* ============================================================
   CARD ACTIONS (Navigation)
============================================================ */

.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  gap: 10px;
  flex-wrap: wrap;
}

.card-actions .btn {
  flex: 1;
  min-width: 100px;
  text-align: center;
}

/* Navigation Buttons - Ägyptisches Design */
.nav-btn {
  flex: 0 0 auto;
  min-width: 50px;
  width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4af37, #b8941f);
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(212,175,55,0.3);
  border: 2px solid rgba(255,255,255,0.3);
  transition: all 0.2s ease;
}

.nav-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(212,175,55,0.4);
  background: linear-gradient(135deg, #e6c759, #c9a52a);
}

.nav-btn:active {
  transform: scale(0.95);
}

/* ============================================================
   LERN-LOGIK BUTTONS
============================================================ */

.learning-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid rgba(0,0,0,0.08);
}

.known-btn {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: white;
  border: 3px solid #4ade80;
  box-shadow: 0 4px 12px rgba(22,163,74,0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-weight: 600;
}

.known-btn:hover {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(22,163,74,0.4);
}

.unknown-btn {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
  border: 3px solid #f87171;
  box-shadow: 0 4px 12px rgba(220,38,38,0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-weight: 600;
}

.unknown-btn:hover {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(220,38,38,0.4);
}

.btn-icon {
  font-size: 18px;
  font-weight: bold;
}

.btn-text {
  font-size: 14px;
}

/* Karten-Markierungen */
.card.learned-known {
  border-left-color: var(--flag-green);
  border-left-width: 6px;
  background: linear-gradient(to right, rgba(22,163,74,0.05), var(--card-bg));
}

.card.learned-unknown {
  border-left-color: var(--flag-red);
  border-left-width: 6px;
  background: linear-gradient(to right, rgba(220,38,38,0.05), var(--card-bg));
}

.card.learned-new {
  border-left-color: rgba(200,200,200,0.5);
}

/* ============================================================
   ANSWER BOX
============================================================ */

.answer {
  background: linear-gradient(135deg, #f0fff0, #e8f5e9);
  padding: 16px;
  border-radius: 12px;
  margin-top: 16px;
  border: 1px solid rgba(47,139,70,0.2);
}

.answer h3 {
  color: var(--accent);
  margin-bottom: 10px;
  font-size: 16px;
}

.hidden { display: none !important; }

/* ============================================================
   STATUS & FOOTER
============================================================ */

.status {
  text-align: center;
  color: rgba(255,255,255,0.9);
  margin: 16px 0;
  padding: 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  font-size: 14px;
}

.footer {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  background: rgba(255,255,255,0.9);
  font-size: 14px;
}

/* ============================================================
   SWIPE ANIMATIONS
============================================================ */

.card.moving { transition: none; }
.card.swipe-left { transform: translateX(-120%) rotate(-3deg); }
.card.swipe-right { transform: translateX(120%) rotate(3deg); }

/* Skarabäus-Button ist jetzt oben bei der Kategorie (siehe .scarab-btn-small) */

/* ============================================================
   EDIT OVERLAY
============================================================ */

.edit-overlay {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 80px;
  background: rgba(255, 255, 255, 0.98);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: 0 15px 50px rgba(0,0,0,0.3);
  z-index: 100;
  max-height: 70vh;
  overflow-y: auto;
}

.edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #eee;
}

.edit-header h3 {
  margin: 0;
  color: var(--accent);
  font-size: 18px;
}

.edit-overlay label {
  display: block;
  font-weight: 600;
  margin-top: 14px;
  margin-bottom: 6px;
  color: #333;
  font-size: 14px;
}

.edit-overlay input,
.edit-overlay textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.edit-overlay input:focus,
.edit-overlay textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.edit-overlay textarea {
  resize: vertical;
  min-height: 60px;
}

.edit-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #eee;
}

.edit-feedback {
  margin-top: 10px;
  font-size: 14px;
  text-align: center;
  font-weight: 500;
}

.btn.small {
  padding: 6px 12px;
  font-size: 14px;
}

/* ============================================================
   TABLET (768px - 1024px)
============================================================ */

@media (min-width: 768px) {
  .topbar .container {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .controls-row {
    justify-content: flex-end;
  }

  .card {
    padding: 28px;
  }

  .card-actions .btn {
    flex: 0 1 auto;
    min-width: 140px;
  }

  .audio-controls {
    flex-wrap: nowrap;
  }

  input[type=range] {
    width: 140px;
  }
}

/* ============================================================
   DESKTOP (1024px+)
============================================================ */

@media (min-width: 1024px) {
  .topbar {
    padding: 20px 0;
  }

  .topbar h1 {
    font-size: 32px;
  }

  .card {
    padding: 32px;
  }

  .card-de {
    font-size: 34px;
  }

  .card-ar {
    font-size: 30px;
  }

  .edit-overlay {
    left: 10%;
    right: 10%;
    bottom: 100px;
    max-width: 600px;
    margin: 0 auto;
  }

  input[type=range] {
    width: 180px;
  }
}

/* ============================================================
   MOBILE (< 768px)
============================================================ */

@media (max-width: 767px) {
  :root {
    --radius: 12px;
  }

  .topbar {
    padding: 12px 0;
  }

  .topbar h1 {
    text-align: center;
    margin-bottom: 8px;
  }

  .controls-row {
    justify-content: center;
    width: 100%;
  }

  .controls-row label {
    font-size: 12px;
  }

  select {
    padding: 8px 10px;
    font-size: 13px;
    min-width: 110px;
  }

  .btn {
    padding: 10px 14px;
    font-size: 13px;
  }

  .page {
    padding: 12px 8px;
    background-attachment: scroll;
  }

  .panel {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .panel select {
    width: 100%;
  }

  .card-wrap {
    padding: 5px;
  }

  .card {
    padding: 16px;
    border-left-width: 5px;
  }

  .card-meta {
    margin-bottom: 8px;
  }

  .card-category {
    font-size: 12px;
    padding: 3px 10px;
  }

  .card-de {
    font-size: 22px;
    margin: 8px 0;
  }

  .card-u {
    font-size: 16px;
  }

  .card-ar {
    font-size: 20px;
    text-align: left;
    direction: ltr;
  }

  .audio-row {
    margin-top: 12px;
    padding-top: 12px;
  }

  .audio-controls {
    justify-content: center;
  }

  input[type=range] {
    width: 80px;
  }

  .card-actions {
    flex-direction: row;
    gap: 8px;
  }

  .card-actions .btn {
    padding: 12px 10px;
    font-size: 13px;
  }

  .card-actions .nav-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .scarab-btn-small {
    width: 24px;
    height: 24px;
  }

  .scarab-symbol {
    font-size: 12px;
  }

  .nav-btn {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .edit-overlay {
    left: 8px;
    right: 8px;
    bottom: 65px;
    padding: 16px;
    max-height: 60vh;
  }

  .edit-header h3 {
    font-size: 16px;
  }

  .edit-overlay input,
  .edit-overlay textarea {
    padding: 10px;
    font-size: 14px;
  }

  .edit-footer {
    flex-direction: column;
  }

  .edit-footer .btn {
    width: 100%;
  }

  .status {
    margin: 12px 8px;
    font-size: 13px;
  }

  .footer {
    padding: 12px;
    font-size: 12px;
  }
}

/* ============================================================
   SMALL MOBILE (< 400px)
============================================================ */

@media (max-width: 400px) {
  .topbar h1 {
    font-size: 18px;
  }

  .controls-row {
    gap: 6px;
  }

  .controls-row label {
    display: none;
  }

  select {
    min-width: 90px;
    font-size: 12px;
  }

  .btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  .card {
    padding: 14px;
  }

  .card-de {
    font-size: 20px;
  }

  .card-u {
    font-size: 15px;
  }

  .card-ar {
    font-size: 18px;
  }

  .card-actions .btn {
    padding: 10px 8px;
    font-size: 12px;
  }
}

/* ============================================================
   LANDSCAPE MOBILE
============================================================ */

@media (max-height: 500px) and (orientation: landscape) {
  .topbar {
    padding: 8px 0;
    position: relative;
  }

  .topbar h1 {
    font-size: 18px;
    display: inline;
  }

  .page {
    padding: 8px;
  }

  .card {
    padding: 12px;
  }

  .card-de {
    font-size: 20px;
    margin: 4px 0;
  }

  .edit-overlay {
    max-height: 80vh;
  }
}

/* ============================================================
   TOUCH DEVICE OPTIMIZATIONS
============================================================ */

@media (hover: none) and (pointer: coarse) {
  .btn:hover {
    transform: none;
    box-shadow: none;
  }

  .btn:active {
    background: rgba(0,0,0,0.1);
  }

  .btn.accent:active {
    background: var(--accent-dark);
  }

  .scarab-btn:hover {
    transform: none;
  }

  .scarab-btn:active {
    transform: scale(0.95);
  }
}

/* ============================================================
   DARK MODE (optional - für System-Präferenz)
============================================================ */

@media (prefers-color-scheme: dark) {
  /* Kann später aktiviert werden */
}

/* ============================================================
   PRINT STYLES
============================================================ */

@media print {
  .topbar,
  .controls-row,
  .panel,
  .audio-row,
  .card-actions,
  .scarab-btn,
  .edit-overlay,
  .status,
  .footer {
    display: none !important;
  }

  .page {
    background: white !important;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }
}
