@use '@angular/material' as mat;

// ---- Themes ----
$light-theme: mat.define-theme((color: (theme-type: light, primary: mat.$cyan-palette, tertiary: mat.$orange-palette ),
      typography: (brand-family: 'Inter, Roboto, Arial, sans-serif', bold-weight: 600),
      density: (scale: 0),
    ));

$dark-theme: mat.define-theme((color: (theme-type: dark, primary: mat.$cyan-palette, tertiary: mat.$orange-palette ),
    ));

// ---- Core + Components ----
@include mat.core-theme($light-theme);
@include mat.all-component-themes($light-theme);


// Dark-Mode
.dark {
  @include mat.all-component-colors($dark-theme);
}

/* ---- Custom variables ---- */
:root {
  --app-maxWidth: 1200px;
  --app-bg: #{mat.get-theme-color($light-theme, surface-container-low)};
  --app-fg: #{mat.get-theme-color($light-theme, on-surface)};
  --app-logo-bg: #313131;
  --app-card-background: #fafafa;
  --app-topbar-bg: var(--app-card-background);

  --card-radius: 18px;
  --card-bg: var(--app-card-background);
  --card-border-inset: rgba(255, 255, 255, 0.35);
  --card-border-inset-dark: rgba(0, 0, 0, 0.35);

  --link-color: #38a7ff;
  --link-color-hover: #66bfff;
}

.dark {
  --app-bg: #{mat.get-theme-color($dark-theme,surface-variant)};
  --app-fg: #{mat.get-theme-color($dark-theme, on-surface)};
  --app-card-background: #313131;
  --app-logo-bg: #313131;
  --app-topbar-bg: var(--app-card-background);

  --card-bg: var(--app-card-background);

  --link-color: #6dbcff;
  --link-color-hover: #9ad2ff;
}

/* ---- global background and tests ---- */
html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, Roboto, Arial, sans-serif;
  background-color: var(--app-bg);
  color: var(--app-fg);
  transition: background-color 220ms ease, color 220ms ease;
}

.material-symbols-outlined {
  font-variation-settings:
    "FILL" 0,
    /* 0 oder 1 */
    "wght" 400,
    /* 100..700 */
    "GRAD" 0,
    /* -50..200 */
    "opsz" 24;
  /* 20..48 */
}

/* smooth transition between theme change */
.mat-toolbar,
.mat-mdc-card,
.mat-sidenav,
.mat-mdc-menu-panel,
.mat-mdc-dialog-container,
.mat-mdc-select-panel,
.mat-mdc-snack-bar-container,
.cdk-overlay-pane {
  transition:
    background-color 220ms ease,
    color 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease,
    fill 220ms ease;
}

/* links */
a {
  color: var(--link-color);
  text-decoration: none;
  font-weight: 500;

  &:hover {
    color: var(--link-color-hover);
    text-decoration: underline;
  }
}

/* cards */
.mat-mdc-card {
  position: relative;
  border-radius: var(--card-radius) !important;
  background: var(--card-bg) !important;
  box-shadow: var(--card-shadow-outer);
  overflow: hidden;

  border: none;

  transition:
    box-shadow 200ms ease,
    transform 200ms ease;

  &.algo-container {
    width: 100%;
    max-width: 1920px;
    padding: 20px;
  }
}

.mat-mdc-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;

  box-shadow:
    inset 0 1px 0 var(--card-border-inset),
    inset 0 -1px 0 var(--card-border-inset-dark);
}

.mat-mdc-card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
}

/* accordion */
/* expansion panels like cards */
.mat-accordion {
  display: grid;
  gap: 8px;
}

.mat-accordion .mat-expansion-panel {
  border-radius: var(--card-radius) !important;
  background: var(--card-bg) !important;
  overflow: hidden;
  /* ok */
  border: none !important;
}


.mat-accordion .mat-expansion-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;

  box-shadow:
    inset 0 1px 0 var(--card-border-inset),
    inset 0 -1px 0 var(--card-border-inset-dark);
}

.mat-accordion .mat-expansion-panel::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
}

.mat-expansion-panel-header {
  background: transparent !important;
}

.mat-expansion-panel-body {
  padding-top: 0;
}

.image-dialog-panel .mat-mdc-dialog-surface {
  border-radius: 16px;
  overflow: hidden;
}

.image-dialog-panel .mat-mdc-dialog-content {
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  max-height: none !important;
}

.image-dialog-panel .mat-mdc-dialog-container {
  padding: 0;
}

.link-row {
  grid-row: 2;
  grid-column: 2;
  margin-top: .1rem;
  opacity: .85;
  vertical-align: center;
}

.link-with-icon {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  line-height: 1;
}

.link-with-icon mat-icon {
  font-size: 18px;
  height: 18px;
  width: 18px;
}

// algos

.algo-container {
  max-width: var(--app-maxWidth);
  gap: clamp(1rem, 3vw, 1.5rem);
  margin-right: 1rem;
  margin-left: 0.5rem;
  margin-top: auto;
}

.algo-info {
  margin: 0 0 1rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;

  h3 {
    margin: 0 0 0.5rem 0;
  }

  p {
    margin: 0.5rem 0;
  }

  a {
    margin-left: 0.25rem;
  }
}

.controls-panel {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.9em;

  mat-button-toggle-group {
    border-radius: 4px;
    overflow: hidden;
  }

  mat-form-field {
    width: 200px;
  }
}

.input-container {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;

  .input-field {
    width: 150px;
  }
}

canvas {
  border: 1px solid lightgray;
  display: block;
  margin: 0 auto;
  max-width: 100%;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  font-size: 0.9em;

  .legend-color {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 1px solid lightgray;
    vertical-align: middle;
    margin-right: 5px;

    &.start {
      background-color: green;
    }

    &.end {
      background-color: red;
    }

    &.wall {
      background-color: black;
    }

    &.visited {
      background-color: skyblue;
    }

    &.path {
      background-color: gold;
    }

    &.empty {
      background-color: lightgray;
    }

    &.alive {
      background-color: black;
    }

    &.L1 {
      background-color: yellow;
    }

    &.L2 {
      background-color: magenta;
    }

    &.M1 {
      background-color: red;
    }

    &.M2 {
      background-color: green;
    }
  }
}

.controls-container {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

/* Sorting Visualization & Canvas */
.sorting-visualization-area,
.visualization-area {
  display: flex;
  align-items: flex-end;
  height: clamp(200px, 40vh, 400px);
  border-bottom: 1px solid var(--app-fg);
  margin-bottom: clamp(10px, 3vw, 20px);
  gap: 1px;
  background-color: var(--card-bg);

  .sorting-bar,
  .bar {
    flex-grow: 1;
    background-color: #424242;
    transition: height 0.05s ease-in-out, background-color 0.05s ease-in-out;
    width: 10px;
    min-width: 1px;

    &.unsorted {
      background-color: #424242;
    }

    &.comparing {
      background-color: #ffeb3b;
    }

    &.sorted {
      background-color: #4caf50;
    }
  }
}

/* ---- Modern Layouts & Typography (Grid, Flex, Clamp) ---- */

.layout-container {
  width: 100%;
  max-width: var(--app-maxWidth);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem);
}

app-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-container {
  width: 100%;
  max-width: var(--app-maxWidth);
  margin: 1rem auto;

}

.app-surface {
  flex-grow: 1;
  color: var(--app-fg);
  transition: background-color 220ms ease, color 220ms ease;
}

.foot {
  border-top: 1px solid rgba(0, 0, 0, .08);
  padding: clamp(1rem, 2vw, 1.5rem);
  text-align: center;
  opacity: .8;
  background: var(--app-bg);
}

/* ---- Menu Overrides ---- */
.mat-mdc-menu-item .mdc-list-item__primary-text {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.mat-mdc-menu-item .kbd {
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  padding: 0 .35rem;
  opacity: .65;
}

.mat-mdc-menu-item .mat-icon {
  width: 20px;
  height: 20px;
  font-size: 20px;
}

.mat-mdc-menu-item .flag-icon {
  width: 20px !important;
  height: 14px !important;
  object-fit: cover;
  border-radius: 2px;
  margin-right: .5rem;
  vertical-align: middle;
}

.mat-mdc-menu-panel {
  border-radius: 10px !important;
  border: 1px solid rgba(0, 0, 0, .14);
}

.dark .mat-mdc-menu-panel {
  border-color: rgba(255, 255, 255, .06);
}

/* ---- About Page Sections ---- */
.about,
.imprint {
  display: grid;
  gap: clamp(1rem, 3vw, 1.5rem);
  max-width: var(--app-maxWidth);
  margin-right: 1rem;
  margin-left: 1rem;
  margin-top: auto;
}

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

.hero-flex-container {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1rem, 4vw, 2rem);
  padding: clamp(1rem, 3vw, 1.5rem);
  align-items: flex-start;

  .photo {
    flex: 1 1 min(100%, 425px);
    max-width: 100%;
    display: flex;
    justify-content: center;

    img {
      display: block;
      width: 100%;
      height: auto;
      max-width: 425px;
      border-radius: 12px;
      box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
      object-fit: cover;
    }
  }

  .intro {
    flex: 999 1 min(100%, 400px);
  }
}

.hero .intro h1 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: clamp(1.5rem, 5vw, 2.5rem);
}

.hero .intro .lead {
  opacity: .9;
  margin: 0.5rem 0 1rem;
  font-size: clamp(1rem, 2.5vw, 1.15rem);
}

.hero .intro .meta {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin-bottom: 0.5rem;
}

.hero .intro .meta .row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
}

.hero .intro .actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}

.skills,
.experience,
.projects,
.education {
  padding: clamp(5px, 2vw, 15px);
}

.skills h2,
.experience h2,
.projects h2,
.education h2 {
  margin-top: .25rem;
  margin-left: .25rem;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
}

.skills .chip-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: clamp(0.5rem, 2vw, 1rem);
  margin-left: .25rem;
  margin-bottom: .5rem;
}

.skills .chip-groups h3 {
  margin: .2rem 0 .4rem;
  font-size: .95rem;
  opacity: .85;
}

.xp-list {
  margin-left: .25rem;
  display: grid;
  gap: clamp(0.75rem, 2vw, 1rem);
}

.xp-item .xp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem;
}

.xp-item .xp-head .time {
  opacity: .75;
  font-size: clamp(0.85rem, 2vw, 0.95rem);
}

.xp-item .xp-sub {
  opacity: .9;
  margin-bottom: .25rem;
}

.xp-item ul {
  margin: .25rem 0 .5rem 1.15rem;
}

.xp-head-grid {
  display: grid;
  grid-template-columns: calc(clamp(32px, 8vw, 48px) + .75rem) 1fr;
  grid-template-rows: auto auto;
  column-gap: clamp(0.5rem, 2vw, .75rem);
}

.logo-wrap {
  grid-row: 1 / span 2;
  grid-column: 1;
  display: flex;
  align-items: center;
}

.company-logo {
  width: clamp(32px, 8vw, 48px);
  height: clamp(32px, 8vw, 48px);
  object-fit: contain;
  opacity: .9;
  border-radius: 10%;
  background-color: var(--app-logo-bg);
}

.head-row {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: clamp(0.25rem, 1vw, 0.5rem) 1rem;
}

.head-row strong {
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
}

.head-row .time {
  opacity: .75;
  font-size: clamp(0.85rem, 2vw, 0.95rem);
}

.company-row {
  grid-row: 2;
  grid-column: 2;
  margin-top: .1rem;
  opacity: .85;
  font-size: clamp(0.85rem, 2vw, 1rem);
}

.highlights {
  margin-top: .4rem;
  margin-left: clamp(0.25rem, 1vw, .75rem);
  padding-left: clamp(0.8rem, 2vw, 1.2rem);
}

.highlights li,
.highlights-noMargin li {
  margin: .2rem 0;
  font-size: clamp(0.9rem, 2vw, 1rem);
}

/* ---- Imprint ---- */
.imprint-card {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.imprint-title {
  margin: 0 0 1rem;
  font-size: clamp(1rem, 3vw, 1.2rem);
  font-weight: 600;
}

.imprint-section {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.imprint-label {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
  margin: 0;
}

/* ---- Projects Page & Dialog ---- */
.card-grid {
  display: grid;
  gap: clamp(1rem, 3vw, 1.5rem);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 450px), 1fr));
  max-width: var(--app-maxWidth);
  margin-right: 1rem;
  margin-left: 1rem;
  margin-top: auto;
}

.algo-card {
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.project-card {
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.project-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.project-card.featured {
  grid-column: 1 / -1;
}

.project-card mat-card-header {
  padding-bottom: 1rem;
}

.project-card mat-card-content {
  flex-grow: 1;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.project-card mat-chip-set {
  padding-top: clamp(0.5rem, 2vw, 1rem);
}

.project-card mat-card-actions {
  margin-top: auto;
}

.icon-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: clamp(150px, 20vw, 200px);
  background-color: #f0f0f0;
}

.fallback-icon {
  font-size: clamp(3rem, 8vw, 4rem);
  width: clamp(3rem, 8vw, 4rem);
  height: clamp(3rem, 8vw, 4rem);
  color: #666;
}

img[mat-card-image] {
  width: 100%;
  height: clamp(150px, 25vw, 250px);
  object-fit: cover;
}

.my-swiper {
  border-radius: 12px;
}

.my-swiper::part(button-prev),
.my-swiper::part(button-next) {
  width: 35px;
  height: 35px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .5);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.my-swiper::part(button-prev):hover,
.my-swiper::part(button-next):hover {
  background: rgba(0, 0, 0, .75);
}

.my-swiper::part(pagination) {
  bottom: 12px;
}

swiper-slide {
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-color: #222;
}

.slide-img {
  width: 100%;
  height: auto;
  max-height: clamp(300px, 60vh, 512px) !important;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.slide-source {
  font-size: 0.75rem;
  color: #aaa;
  background: #2a2a2a;
  padding: 0.5rem;
  text-align: right;
  border-top: 1px solid #444;
}

.link-section {
  display: flex;
  gap: clamp(0.5rem, 2vw, 1rem);
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* ---- Shared Elements ---- */
.canvas-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.canvas-container canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  min-width: 200px;
  max-width: 1000px;
  touch-action: none;
  border: none;
  border-radius: clamp(10px, 2vw, 20px);
  outline: none;
}

.category-cards {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.5rem, 2vw, 1rem);
  margin-top: clamp(1rem, 3vw, 2rem);
}

.category-cards mat-card {
  cursor: pointer;
  flex: 1 1 300px;
  min-width: 300px;
  max-width: 450px;
}

.category-cards mat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.sorting-card {
  width: 100%;
  max-width: 1920px;
  padding: clamp(10px, 3vw, 20px);
}

.sorting-card .controls-panel {
  display: flex;
  gap: clamp(5px, 2vw, 10px);
  margin-bottom: clamp(10px, 3vw, 20px);
  align-items: center;
  flex-wrap: wrap;
}

.sorting-card .controls-panel mat-form-field {
  width: clamp(150px, 20vw, 200px);
}

.sorting-card .info-panel {
  margin-top: 10px;
  font-size: 0.9em;
}
