@import url("https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,700;9..40,800&family=Noto+Sans+Arabic:wght@400;500;600;700&display=swap");

/* =========================================================
   WORTDAF — playful learning interface
========================================================= */

:root {
  /* Surfaces */
  --canvas: #f3f7f4;
  --surface: #ffffff;
  --surface-soft: #f7faf8;

  /* Text */
  --ink: #173229;
  --ink-soft: #4a5f57;
  --muted: #6f8078;

  /* Lines */
  --line: #dfe7e2;
  --line-strong: #c9d6cf;

  /* Brand */
  --green: #22b573;
  --green-dark: #178a57;
  --green-soft: #e2f6ec;
  --green-border: #a8d9c2;

  --yellow: #ffb703;
  --yellow-dark: #d98f00;
  --yellow-soft: #fff4d6;

  --blue: #2f80ed;
  --blue-soft: #e5effd;

  --red: #e5533d;
  --red-soft: #fdeae6;

  /* Shape */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Elevation */
  --shadow-card: 0 2px 0 rgba(23, 50, 41, 0.06);
  --shadow-button: 0 4px 0 var(--green-dark);
  --shadow-button-active: 0 1px 0 var(--green-dark);

  --transition: 140ms ease;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;

  background: var(--canvas);
  color: var(--ink);
  font-family: "DM Sans", "Noto Sans Arabic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

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

:focus-visible {
  outline: 3px solid rgba(34, 181, 115, 0.45);
  outline-offset: 2px;
}

/* =========================================================
   Header
========================================================= */

header {
  position: sticky;
  top: 0;
  z-index: 30;

  display: flex;
  align-items: center;
  gap: 14px;

  height: 72px;
  padding-inline: clamp(16px, 4vw, 40px);

  background: var(--surface);
  border-bottom: 2px solid var(--line);
}

.brand-logo {
  display: block;
  width: clamp(110px, 18vw, 200px);
  flex-shrink: 0;
  height: auto;
  max-width: 100%;
  object-fit: contain;
}

.tag {
  margin-left: auto;
  padding: 8px 14px;

  background: var(--yellow-soft);
  color: var(--yellow-dark);
  border: 2px solid #f4d488;
  border-radius: var(--radius-pill);

  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

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

main {
  display: block;
  width: 94%;
  max-width: 1500px;
  margin-inline: auto;
  min-height: calc(100dvh - 72px);
}

section {
  min-width: 0;
  padding: 28px clamp(16px, 3vw, 36px) 56px;
}

/* =========================================================
   Sidebar
========================================================= */

.label {
  margin: 0 0 8px;

  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

aside h2 {
  margin: 0 0 22px;

  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.level {
  margin-bottom: 8px;
  padding: 13px 14px;

  background: var(--surface-soft);
  border: 2px solid transparent;
  border-radius: var(--radius-md);

  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}

.level span {
  margin-left: 8px;

  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.level:hover {
  background: var(--green-soft);
  border-color: var(--green-border);
}

.level.active {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green-dark);
}

.level.active span {
  color: var(--green-dark);
}

.tip {
  margin-top: 40px;
  padding: 18px;

  background: var(--yellow-soft);
  border: 2px solid #f4d488;
  border-radius: var(--radius-lg);
}

.tip b {
  display: block;
  margin-bottom: 6px;

  color: var(--yellow-dark);
  font-size: 14px;
  font-weight: 800;
}

.tip p {
  color: #7a6320;
  font-size: 13px;
  line-height: 1.6;
}

/* =========================================================
   Lesson controls
========================================================= */

.crumb {
  margin-bottom: 18px;

  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.selectors {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.6fr;
  gap: 12px;
  margin-bottom: 18px;
  padding: 18px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
}

.selector-item {
  min-width: 0;
}

.selector-item select {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selector-item {
  display: grid;
  gap: 7px;
}

.selector-item label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.selector-item select {
  min-height: 46px;
  padding: 10px 12px;

  background: var(--surface-soft);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);

  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.selector-item select:focus,
.listhead input:focus,
.listhead select:focus,
.input:focus,
.answerinput:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(34, 181, 115, 0.16);
  outline: none;
}

.lesson-status {
  display: inline-block;
  margin: 0 0 18px;
  padding: 9px 14px;

  background: var(--green-soft);
  color: var(--green-dark);
  border: 2px solid var(--green-border);
  border-radius: var(--radius-pill);

  font-size: 12px;
  font-weight: 800;
}

/* =========================================================
   Lesson header
========================================================= */

.hero {
  padding: 26px;

  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
}

.hero .label {
  color: var(--green);
}

.hero h1 {
  max-width: 22ch;
  margin: 8px 0 10px;

  font-size: clamp(28px, 3.4vw, 42px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.hero p {
  max-width: 58ch;

  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.65;
}

/* =========================================================
   Stats
========================================================= */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;

  margin: 16px 0 32px;
}

.stats > div {
  padding: 16px 18px;

  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
}

.stats small {
  display: block;

  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats b {
  display: block;
  margin-top: 4px;

  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stats > div:nth-child(1) b {
  color: var(--green);
}

.stats > div:nth-child(2) b {
  color: var(--blue);
}

.stats > div:nth-child(3) b {
  color: var(--yellow-dark);
}

/* =========================================================
   Learning modes
========================================================= */

.modes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;

  margin: 16px 0 36px;
}

.modes button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;

  min-height: 158px;
  padding: 18px 16px;

  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);

  text-align: left;
  transition:
    transform var(--transition),
    border-color var(--transition),
    background var(--transition),
    box-shadow var(--transition);
}

.modes button:hover {
  border-color: var(--green-border);
  background: var(--green-soft);
  transform: translateY(-3px);
}

.modes button:active {
  transform: translateY(0);
}

.mode-icon {
  display: grid;
  place-items: center;

  width: 42px;
  height: 42px;

  background: var(--green-soft);
  border: 2px solid var(--green-border);
  border-radius: 12px;

  color: var(--green-dark);
  font-size: 18px;
  font-weight: 800;
}

.modes button:nth-child(2) .mode-icon {
  background: var(--blue-soft);
  border-color: #b8d1f5;
  color: var(--blue);
}

.modes button:nth-child(3) .mode-icon {
  background: var(--yellow-soft);
  border-color: #f4d488;
  color: var(--yellow-dark);
}

.modes button:nth-child(4) .mode-icon {
  background: var(--red-soft);
  border-color: #f3bcae;
  color: var(--red);
}

.modes b {
  display: block;

  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.modes small {
  display: block;

  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* =========================================================
   Vocabulary list
========================================================= */

.listhead {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;

  margin-bottom: 14px;
}

.listhead h2 {
  margin-right: auto;

  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.input,
.listhead input,
.listhead select {
  min-height: 44px;
  padding: 10px 13px;

  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);

  font-size: 13px;
  font-weight: 600;
}

.listhead input {
  width: 180px;
}

.tablebox {
  overflow: auto;

  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  min-width: 700px;

  border-collapse: collapse;
}

th {
  padding: 15px 16px;

  background: var(--surface-soft);
  border-bottom: 2px solid var(--line);

  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 14px 16px;

  border-top: 2px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--green-soft);
}

.de {
  font-size: 15px;
  font-weight: 800;
}

.meaning {
  display: inline-block;

  font-family: "Noto Sans Arabic", system-ui, sans-serif;
  direction: rtl;
  text-align: right;
  line-height: 1.7;
}

.forms {
  color: var(--muted);
  font-size: 12px;
}

.sectiontag {
  margin-left: 6px;
  padding: 4px 8px;

  background: var(--blue-soft);
  color: var(--blue);
  border-radius: var(--radius-pill);

  font-size: 10px;
  font-weight: 800;
}

.learn {
  padding: 8px 12px;

  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-pill);

  color: var(--green-dark);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}

.learn:hover {
  background: var(--green-soft);
  border-color: var(--green);
}

.learn.done {
  background: var(--green);
  border-color: var(--green-dark);
  color: #ffffff;
}

.note {
  margin-top: 14px;

  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

/* =========================================================
   Modal
========================================================= */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;

  display: grid;
  place-items: center;
  padding: 18px;

  background: rgba(18, 44, 35, 0.55);
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

.dialog {
  position: relative;

  display: flex;
  flex-direction: column;

  width: min(620px, 100%);
  max-height: calc(100dvh - 36px);
  padding: 28px;

  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 24px;
}

.dialog #mtitle {
  flex-shrink: 0;
  padding-right: 42px;

  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.dialog #body {
  min-height: 0;
  margin-top: 18px;
  padding-right: 4px;

  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;

  display: grid;
  place-items: center;

  width: 38px;
  height: 38px;

  background: var(--surface-soft);
  border: 2px solid var(--line);
  border-radius: 12px;

  color: var(--ink-soft);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.close:hover {
  background: var(--red-soft);
  border-color: #f3bcae;
  color: var(--red);
}

/* =========================================================
   Exercises
========================================================= */

.card {
  margin: 18px 0;
  padding: 28px 20px;

  background: var(--green-soft);
  border: 2px solid var(--green-border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.card .label {
  color: var(--green-dark);
}

.bigword {
  margin: 12px 0 18px;

  font-size: 32px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.answer {
  margin: 14px 0;

  color: var(--green-dark);
  font-family: "Noto Sans Arabic", system-ui, sans-serif;
  font-size: 24px;
  font-weight: 700;
  direction: rtl;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;

  margin-top: 14px;
}

.primary,
.secondary,
.option {
  min-height: 48px;
  padding: 12px 18px;

  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  transition:
    transform var(--transition),
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

.primary {
  background: var(--green);
  border: 0;
  border-bottom: 4px solid var(--green-dark);
  box-shadow: none;
  color: #ffffff;
}

.primary:hover:not(:disabled) {
  background: #26c07b;
}

.primary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: var(--shadow-button-active);
}

.secondary,
.option {
  background: var(--surface);
  border: 2px solid var(--line);
  color: var(--ink);
}

.secondary:hover,
.option:hover:not(:disabled) {
  background: var(--green-soft);
  border-color: var(--green-border);
}

.secondary:active,
.option:active:not(:disabled) {
  transform: translateY(2px);
}

.options {
  display: grid;
  gap: 10px;

  margin: 18px 0;
}

.option {
  min-height: 54px;
  padding: 14px 16px;

  border-radius: var(--radius-md);
  text-align: left;
  font-size: 15px;
}

.feedback {
  min-height: 28px;
  margin: 10px 0;

  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}

.feedback p {
  margin: 6px 0;
}

.answerinput {
  width: 100%;
  margin: 8px 0 14px;
  padding: 14px 16px;

  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);

  font-family: "Noto Sans Arabic", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 600;
  direction: rtl;
}

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

@media (max-width: 700px) {
  header {
    height: 64px;
    padding-inline: 16px;
  }

  main {
    display: block;
  }

  aside {
    display: none;
  }

  section {
    padding: 20px 14px 36px;
  }

  .selectors {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .hero {
    padding: 20px 18px;
    border-radius: 18px;
  }

  .hero h1 {
    font-size: 30px;
  }

  .stats {
    gap: 8px;
    margin-bottom: 26px;
  }

  .stats > div {
    padding: 12px;
    border-radius: 12px;
  }

  .stats b {
    font-size: 22px;
  }

  .modes {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 28px;
  }

  .modes button {
    min-height: auto;
    padding: 14px;
    border-radius: 16px;
  }

  .listhead h2 {
    width: 100%;
  }

  .listhead input,
  .listhead select {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .tablebox {
    border-radius: 16px;
  }

  .dialog {
    padding: 22px 16px;
    border-radius: 20px;
  }

  .card {
    padding: 22px 16px;
  }

  .bigword {
    font-size: 27px;
  }

  .answer {
    font-size: 21px;
  }
}

/* =========================================================
   Reduced motion
========================================================= */

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

.article-svg {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

/* =========================================
   WORTDAF — Mobile Vocabulary Cards
========================================= */

@media (max-width: 700px) {
  /* Remove horizontal table layout */

  .tablebox {
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
  }

  table {
    display: block;
    width: 100%;
    min-width: 0;
    border-collapse: separate;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
    width: 100%;
  }

  /* Each vocabulary row becomes a card */

  tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 14px 15px;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
  }

  tbody tr:hover {
    background: var(--surface);
  }

  tbody td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    font-size: 13px;
  }

  /* German word */

  tbody td:nth-child(1) {
    margin-bottom: 9px;
    line-height: 1.6;
  }

  .de {
    display: inline;
    font-size: 16px;
    line-height: 1.6;
    overflow-wrap: anywhere;
  }

  /* Section tag */

  .sectiontag {
    display: inline-block;
    margin: 5px 0 0 5px;
    padding: 4px 8px;
    font-size: 10px;
    line-height: 1.5;
    vertical-align: middle;
    white-space: normal;
    max-width: 100%;
  }

  /* Dari meaning */

  tbody td:nth-child(2) {
    padding-top: 9px;
    border-top: 1px solid var(--line);
    text-align: right;
  }

  .meaning {
    display: block;
    width: 100%;
    font-size: 14px;
    line-height: 1.9;
    overflow-wrap: anywhere;
  }

  /* Form / Hint */

  tbody td:nth-child(3) {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
  }

  .forms {
    font-size: 12px;
  }

  /* Learned button */

  tbody td:nth-child(4) {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    text-align: left;
  }

  .learn {
    min-height: 36px;
    padding: 7px 13px;
    font-size: 11px;
  }

  /* Vocabulary list controls */

  .listhead {
    gap: 8px;
  }

  .listhead h2 {
    margin-bottom: 4px;
  }

  .listhead input,
  .listhead select {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }
}

.mode-svg {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

/* =========================================
   Favorites
========================================= */

.favorite-toggle {
  padding: 5px 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  transition: color var(--transition);
}

.favorite-toggle:hover,
.favorite-toggle.active {
  color: var(--yellow-dark);
}

.favorites-main-btn {
  min-height: 42px;
  padding: 9px 14px;
  background: var(--green-soft);
  color: var(--green-dark);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition);
}

.favorites-main-btn:hover {
  background: #d3efdf;
}

.favorite-list {
  display: grid;
  gap: 12px;
}

.favorite-item {
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.favorite-word {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.favorite-word strong {
  font-size: 19px;
  font-weight: 800;
}

.favorite-word span {
  color: var(--muted);
  font-size: 12px;
}

.favorite-sentence {
  display: block;
  width: 100%;
  min-height: 85px;
  margin-top: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  resize: vertical;
  font: inherit;
  direction: ltr;
}

.favorite-sentence:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 181, 115, 0.12);
}

.favorite-remove {
  margin-top: 10px;
  padding: 7px 11px;
  background: var(--red-soft);
  border: 1px solid #f3bcae;
  border-radius: 7px;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.favorite-remove:hover {
  background: #fbded8;
}
