/* DerDieDas — design system espelhando o app iOS. */

:root {
  color-scheme: light dark;

  --der: #0a84ff;
  --die: #ff375f;
  --das: #30d158;

  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #000000;
  --secondary: #6c6c70;
  --separator: #c6c6c8;
  --tint: #0a84ff;
  --field: #e4e4e9;
  --header-bg: rgba(242, 242, 247, 0.82);

  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, sans-serif;
  --font-rounded: ui-rounded, 'SF Pro Rounded', -apple-system, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #ffffff;
    --secondary: #98989f;
    --separator: #38383a;
    --field: #1c1c1e;
    --header-bg: rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; }

/* Precisa vir com !important: regras de classe como .training-card{display:flex}
   têm a mesma especificidade do [hidden] da folha do navegador e venceriam por ordem. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
}

/* ------------------------------------------------------------------ header */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(env(safe-area-inset-top), 10px) 16px 8px;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.app-header h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--tint);
  cursor: pointer;
}

.icon-button svg { width: 24px; height: 24px; }
.icon-button:active { opacity: 0.5; }

/* -------------------------------------------------------------------- main */

main {
  flex: 1;
  padding: 4px 16px calc(16px + env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------------ busca */

.search-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--field);
}

.search-bar svg { width: 19px; height: 19px; color: var(--secondary); flex: none; }

.search-bar input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
}

.search-bar input:focus { outline: none; }
.search-bar input::placeholder { color: var(--secondary); }

/* usamos nosso próprio botão de limpar */
.search-bar input::-webkit-search-cancel-button,
.search-bar input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

.clear-button {
  display: none;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--secondary);
  color: var(--card);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.search-bar.has-text .clear-button { display: grid; }

/* ------------------------------------------------------------------- listas */

.section-title {
  margin: 22px 4px 7px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
}

.card {
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-top: 0.5px solid var(--separator);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.row:first-child { border-top: 0; }
.row:active { background: var(--field); }

.row-text { flex: 1; min-width: 0; }

.row-word {
  font-size: 17px;
  font-weight: 600;
}

.row-sub {
  margin-top: 2px;
  font-size: 15px;
  color: var(--secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  margin-top: 3px;
  font-size: 13px;
  color: var(--secondary);
}

/* ------------------------------------------------------------------- badge */

.badge {
  flex: none;
  display: inline-block;
  border-radius: 8px;
  color: #fff;
  font-family: var(--font-rounded);
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.badge[data-article='DER'] { background: var(--der); }
.badge[data-article='DIE'] { background: var(--die); }
.badge[data-article='DAS'] { background: var(--das); }

/* ---------------------------------------------------------- card destacado */

.noun-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  padding: 22px 18px 26px;
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
}

.noun-card .eye {
  position: absolute;
  top: 10px;
  right: 10px;
}

.noun-card .word {
  font-family: var(--font-rounded);
  font-size: 34px;
  font-weight: 600;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.noun-card .label {
  font-size: 12px;
  color: var(--secondary);
}

.noun-card .translation {
  font-size: 20px;
  font-weight: 500;
}

.noun-card .plural {
  font-size: 15px;
  color: var(--secondary);
}

.report-link {
  margin-top: 4px;
  color: var(--secondary);
  font-size: 13px;
  text-decoration: none;
}

.report-link:active { opacity: 0.5; }

/* ------------------------------------------------------------------ treino */

.training-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 26px 18px;
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
}

.training-word {
  font-family: var(--font-rounded);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.article-buttons {
  display: flex;
  gap: 11px;
  flex-wrap: wrap;
  justify-content: center;
}

.article-button {
  min-width: 84px;
  padding: 13px 20px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-family: var(--font-rounded);
  font-size: 19px;
  font-weight: 900;
  cursor: pointer;
}

.article-button[data-article='DER'] { background: var(--der); }
.article-button[data-article='DIE'] { background: var(--die); }
.article-button[data-article='DAS'] { background: var(--das); }
.article-button:active { opacity: 0.65; }

.answer-field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--separator);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
}

.answer-field:focus { outline: 2px solid var(--tint); outline-offset: -1px; }

.feedback {
  min-height: 24px;
  font-size: 17px;
  font-weight: 600;
}

.feedback.correct { color: var(--das); }
.feedback.wrong { color: var(--die); }

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-top: 0.5px solid var(--separator);
  font-size: 17px;
}

.control-row:first-child { border-top: 0; }

select {
  border: 0;
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--field);
  color: var(--text);
  font: inherit;
}

/* interruptor */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--separator);
  transition: background 0.2s;
  pointer-events: none;
}
.switch span::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.switch input:checked + span { background: var(--das); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ------------------------------------------------------------- estatísticas */

.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-top: 0.5px solid var(--separator);
  font-size: 15px;
}

.stat-row:first-child { border-top: 0; }
.stat-row .value { color: var(--secondary); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------- sobre */

.about p {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.55;
}

.about .card p { padding: 0 14px; }
.about .card p:first-child { padding-top: 13px; }
.about .card p:last-child { padding-bottom: 13px; margin-bottom: 0; }

.about-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 0 6px;
  text-align: center;
}

.about-header img { width: 76px; height: 76px; border-radius: 17px; }
.about-header .name { font-size: 21px; font-weight: 600; }
.about-header .version { font-size: 13px; color: var(--secondary); }

a { color: var(--tint); }

.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 0.5px solid var(--separator);
  font-size: 16px;
  text-decoration: none;
}

.link-row:first-child { border-top: 0; }
.link-row::after { content: '›'; color: var(--secondary); font-size: 20px; }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--secondary);
}

.empty strong { display: block; margin-bottom: 5px; font-size: 17px; color: var(--text); }

/* ----------------------------------------------------------------- tab bar */

.tabbar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  border-top: 0.5px solid var(--separator);
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 0;
  border: 0;
  background: none;
  color: var(--secondary);
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
}

.tab svg { width: 25px; height: 25px; }
.tab[aria-selected='true'] { color: var(--tint); }

/* --------------------------------------------------------------- carregando */

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--secondary);
  font-size: 15px;
}

.loading[hidden] { display: none; }

@media (min-width: 700px) {
  .app { max-width: 640px; margin: 0 auto; }
}
