/*
 * Pluspunkte UI Framework
 * https://janismueller.ch/pluspunkte.css
 *
 * Einbinden:
 * <link rel="stylesheet" href="https://janismueller.ch/pluspunkte.css">
 */

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

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
}

input,
select {
  font-family: inherit;
}

a {
  color: inherit;
}


/* =========================================================
   Design Tokens – Light Mode
   ========================================================= */

:root {
  --background:       hsl(220, 20%, 97%);
  --foreground:       hsl(224, 60%, 8%);
  --border:           hsl(220, 16%, 88%);
  --card:             hsl(0, 0%, 100%);
  --muted:            hsl(220, 16%, 93%);
  --muted-foreground: hsl(220, 12%, 46%);
  --primary:          hsl(230, 100%, 60%);
  --primary-foreground: #fff;
  --destruct:         hsl(350, 80%, 50%);
  --radius:           .5rem;

  --chip-green-text:       hsl(142, 55%, 32%);
  --chip-green-background: hsla(142, 55%, 32%, .10);
  --chip-green-border:     hsla(142, 55%, 32%, .25);

  --chip-yellow-text:       hsl(40, 80%, 30%);
  --chip-yellow-background: hsla(40, 80%, 30%, .10);
  --chip-yellow-border:     hsla(40, 80%, 30%, .25);

  --chip-red-text:       hsl(350, 75%, 45%);
  --chip-red-background: hsla(350, 75%, 45%, .10);
  --chip-red-border:     hsla(350, 75%, 45%, .25);

  --accent-green:  hsl(142, 55%, 32%);
  --accent-yellow: hsl(40, 80%, 30%);
  --accent-red:    hsl(350, 75%, 45%);
}


/* =========================================================
   Design Tokens – Dark Mode
   ========================================================= */

html.dark {
  --background:       hsl(230, 35%, 8%);
  --foreground:       hsl(210, 40%, 98%);
  --border:           hsl(230, 30%, 20%);
  --card:             hsl(230, 35%, 12%);
  --muted:            hsl(230, 30%, 18%);
  --muted-foreground: hsl(215, 20%, 65%);
  --primary:          hsl(230, 100%, 65%);
  --primary-foreground: #fff;
  --destruct:         hsl(350, 80%, 50%);

  --chip-green-text:       hsl(142, 70%, 45%);
  --chip-green-background: hsla(142, 70%, 45%, .12);
  --chip-green-border:     hsla(142, 70%, 45%, .25);

  --chip-yellow-text:       hsl(45, 93%, 47%);
  --chip-yellow-background: hsla(45, 93%, 47%, .12);
  --chip-yellow-border:     hsla(45, 93%, 47%, .25);

  --chip-red-text:       hsl(350, 80%, 60%);
  --chip-red-background: hsla(350, 80%, 50%, .12);
  --chip-red-border:     hsla(350, 80%, 50%, .25);

  --accent-green:  hsl(142, 70%, 45%);
  --accent-yellow: hsl(45, 93%, 47%);
  --accent-red:    hsl(350, 80%, 60%);
}


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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--background);
  color: var(--foreground);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  max-width: none;
  padding: 0;
  margin: 0;
}


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

#app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

html.dark #app-header {
  background: hsla(230, 35%, 8%, .9);
  backdrop-filter: blur(12px);
}

html:not(.dark) #app-header {
  background: hsla(220, 20%, 97%, .9);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem;
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

@media (min-width: 640px) {
  .header-inner {
    padding: 0 1.5rem;
  }
}

.header-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.logo-icon {
  width: 2.25rem;
  height: 2.25rem;
  background: hsla(230, 100%, 65%, .15);
  border: 1px solid hsla(230, 100%, 65%, .3);
  border-radius: .625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.logo-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

#stats,
#header-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-right: .25rem;
}

.header-stat,
.hstat {
  text-align: right;
  display: none;
}

@media (min-width: 640px) {
  .header-stat,
  .hstat {
    display: block;
  }
}

.header-stat-label,
.hstat-label {
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted-foreground);
  font-family: 'Space Mono', monospace;
}

.header-stat-value,
.hstat-val {
  font-weight: 600;
  font-size: .9rem;
}

.header-stat-value.mono,
.hstat-val.mono {
  font-family: 'Space Mono', monospace;
  font-size: 1.1rem;
  font-weight: 700;
}

.divider-v {
  width: 1px;
  height: 2rem;
  background: var(--border);
  flex-shrink: 0;
}

.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: .625rem;
  background: transparent;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--foreground);
  background: hsla(0, 0%, 50%, .1);
}

.icon-btn-danger:hover {
  color: hsl(350, 75%, 65%);
}


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

.page-main {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem 5rem;
}

@media (min-width: 640px) {
  .page-main {
    padding: 0 1.5rem 5rem;
  }
}


/* =========================================================
   Buttons
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  padding: .5rem 1rem;
  transition: filter .15s, background .15s, opacity .15s;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}

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

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-outline,
.btn-ghost {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  background: var(--muted);
}

.btn-danger {
  background: hsl(350, 72%, 52%);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.1);
}


/* =========================================================
   Inputs
   ========================================================= */

.input {
  width: 100%;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-size: .875rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.input:focus {
  border-color: hsla(230, 100%, 65%, .6);
  box-shadow: 0 0 0 3px hsla(230, 100%, 65%, .15);
}

.input.mono {
  font-family: 'Space Mono', monospace;
}


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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn .2s ease;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  position: relative;
  border-radius: 1rem;
  padding: 2rem;
  width: 100%;
  max-width: 24rem;
  animation: zoomIn .2s ease;
  box-shadow: 0 25px 60px rgba(0, 0, 0, .55);
}

html.dark .modal-card {
  background: hsl(230, 35%, 8%);
  border: 1px solid hsla(0, 0%, 100%, .10);
}

html:not(.dark) .modal-card {
  background: #fff;
  border: 1px solid hsla(0, 0%, 0%, .08);
}


/* =========================================================
   Form
   ========================================================= */

.form-group {
  display: flex;
  flex-direction: column;
  gap: .375rem;
}

.form-label {
  font-size: .875rem;
  font-weight: 500;
}


/* =========================================================
   Empty State
   ========================================================= */

.empty-state {
  text-align: center;
  padding: 5rem 1rem;
  background: hsla(0, 0%, 50%, .03);
  border-radius: 1rem;
  border: 1px dashed hsla(0, 0%, 50%, .15);
}

.empty-icon {
  width: 4rem;
  height: 4rem;
  background: hsla(0, 0%, 50%, .08);
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: var(--muted-foreground);
}

.empty-state h3 {
  font-size: 1.25rem;
  margin-bottom: .5rem;
  color: hsl(215, 15%, 40%) !important;
}

.empty-state p {
  color: var(--muted-foreground);
  margin-bottom: 1.5rem;
}


/* =========================================================
   Utility Classes
   ========================================================= */

.text-green  { color: var(--accent-green); }
.text-yellow { color: var(--accent-yellow); }
.text-red    { color: var(--accent-red); }
.text-muted  { color: var(--muted-foreground); }

.mono   { font-family: 'Space Mono', monospace; }
.hidden { display: none !important; }


/* =========================================================
   Animations
   ========================================================= */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* =========================================================
   Summary Bar
   ========================================================= */

.summary-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .summary-bar {
    gap: 1rem;
  }
}

.stat-card {
  background: hsla(0, 0%, 50%, .04);
  border: 1px solid hsla(0, 0%, 50%, .08);
  border-radius: var(--radius);
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .125rem;
}

@media (min-width: 640px) {
  .stat-card {
    padding: 1rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.stat-card-label,
.sc-label {
  font-size: .75rem;
  color: var(--muted-foreground);
}

.stat-card-value,
.sc-val {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Space Mono', monospace;
}

@media (min-width: 640px) {
  .stat-card-value,
  .sc-val {
    font-size: 1.25rem;
  }
}


/* =========================================================
   Add Form
   ========================================================= */

.add-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 640px) {
  .add-form {
    flex-direction: row;
  }
}

.add-form .input {
  flex: 1;
  height: 3rem;
  font-size: 1rem;
}

.add-form .btn {
  height: 3rem;
  padding: 0 1.5rem;
  flex-shrink: 0;
}


/* =========================================================
   Subject Cards
   ========================================================= */

.subjects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .subjects-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.subject-card {
  background: var(--card);
  border: 1px solid hsla(0, 0%, 50%, .12);
  border-radius: .75rem;
  overflow: hidden;
  transition: border-color .15s;
  animation: slideUp .3s ease;
}

.subject-card:hover {
  border-color: hsla(230, 100%, 65%, .3);
}

.subject-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid hsla(0, 0%, 50%, .1);
  background: hsla(0, 0%, 50%, .03);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}

.subject-name {
  font-size: 1.2rem;
  font-weight: 600;
}

.subject-stats {
  display: flex;
  gap: 1rem;
  margin-top: .5rem;
}

.subject-stat-label,
.ss-label {
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted-foreground);
}

.subject-stat-value,
.ss-val {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: .9rem;
}

.subject-body {
  padding: 1.25rem;
}

.grades-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
  min-height: 2rem;
}

.no-grades {
  font-size: .875rem;
  color: var(--muted-foreground);
  font-style: italic;
  line-height: 2rem;
}


/* =========================================================
   Grade Chips
   ========================================================= */

.chip {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .375rem .625rem;
  border-radius: .375rem;
  border: 1px solid;
  font-size: .875rem;
  font-family: 'Space Mono', monospace;
  animation: slideUp .2s ease;
}

.chip-info {
  display: flex;
  flex-direction: column;
}

.chip-grade {
  font-weight: 700;
}

.chip-meta {
  font-size: .6rem;
  line-height: 1.2;
  opacity: .7;
}

.chip-green {
  color: var(--chip-green-text);
  background: var(--chip-green-background);
  border-color: var(--chip-green-border);
}

.chip-yellow {
  color: var(--chip-yellow-text);
  background: var(--chip-yellow-background);
  border-color: var(--chip-yellow-border);
}

.chip-red {
  color: var(--chip-red-text);
  background: var(--chip-red-background);
  border-color: var(--chip-red-border);
}

.del-grade-btn {
  background: none;
  padding: .2rem;
  margin: -.2rem -.2rem -.2rem .1rem;
  border-radius: .25rem;
  color: inherit;
  opacity: 1;
  transition: opacity .15s, color .15s;
  touch-action: manipulation;
}

.del-grade-btn:hover {
  color: var(--destruct);
}

@media (hover: hover) {
  .del-grade-btn {
    opacity: 0;
  }
  .chip:hover .del-grade-btn {
    opacity: 1;
  }
}

.btn-grade {
  width: 100%;
  height: 2.5rem;
  background: hsla(230, 100%, 65%, .10);
  color: var(--primary);
  border: 1px solid hsla(230, 100%, 65%, .22);
  touch-action: manipulation;
}

.btn-grade:hover {
  background: hsla(230, 100%, 65%, .18);
}


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

.grade-modal-card {
  max-width: 26rem;
}

.grade-modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

#gm-form,
#grade-modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.grade-modal-footer {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: .25rem;
}
