/* ======== Theming ======== */

:root {
  --accent-color: #fc0;
  
  --default-border-color: #aaa;
  --default-border-radius--rounded: 8px;
  --default-border-radius--rounded-sm: 4px;
  --default-font-family:
    'Funnel Sans',
    'Open Sans',
    'Helvetica Neue',
    Arial,
    sans-serif;
  --default-font-family--data:
    Menlo,
    'Courier New',
    'Open Sans',
    'Helvetica Neue',
    Arial,
    sans-serif;
  --default-font-family--mono:
    Menlo,
    'Courier New',
    Courier,
    mono;
  --default-padding: 16px;
  --default-padding--xs: 4px;
  --default-padding--sm: 8px;
  --default-padding--lg: 32px;

  --a-color: oklch(from var(--accent-color) 0.5 0.15 calc(h + 135));

  --button-background--primary: var(--accent-color);
  --button-background--secondary: #fff;
  --button-border-color--primary: oklch(from var(--button-background--primary) calc(l * 0.9) c h);
  --button-border-color--secondary: oklch(from var(--button-background--secondary) calc(l * 0.8) c h);
  --button-border-radius: var(--default-border-radius--rounded);
  --button-color--primary: #000;
  --button-color--secondary: #000;
  --button-font-family: var(--default-font-family);
  --button-font-size: 1rem;
  --button-font-size--small: 0.9rem;
  --button-padding--default: var(--default-padding--sm) var(--default-padding);
  --button-padding--small: var(--default-padding--xs) var(--default-padding--sm);
  --button-padding: var(--button-padding--default);
  --button-shadow: 0 2px 2px #3331;

  --popover-border-color: var(--default-border-color);
  --popover-shadow: 0 8px 8px #3333;
}

/* ======== Global Setup ======== */

@font-face {
  font-family: "Funnel Sans";
  src: url("../funnel_sans/funnel_sans_variable.ttf");
}

@view-transitions {
  navigation: auto;
}

/* https://css-tricks.com/inclusively-hidden/ */
.sr-only:not(:focus):not(:active) {
  clip: rect(0 0 0 0); 
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap; 
  width: 1px;
}

/* ======== Basic Elements / Style Resets ======== */

html {
  font-family: var(--default-font-family);
}

button {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  box-sizing: border-box;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
}

input[type="text"] {
  appearance: none;
  background: none;
  border: none;
  box-sizing: border-box;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  outline: none;
}

a {
  color: var(--a-color);
  text-decoration: none;
}

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

.text--data {
  font-family: var(--default-font-family--data);
}

.padded {
  padding: var(--default-padding);
}

.padded-sm {
  padding: var(--default-padding--sm);
}

.padded--lg {
  padding: var(--default-padding--lg);
}

/* ======== Components: Buttons ======== */

.button {
  --button-color: inherit;

  background: var(--button-background);
  border: solid 1px var(--button-border-color);
  border-radius: var(--button-border-radius);
  box-shadow: var(--button-shadow);
  color: var(--button-color);
  font-family: var(--button-font-family);
  font-size: var(--button-font-size);
  padding: var(--button-padding);
  text-decoration: none;
  transition: background 0.2s ease;

  &:hover {
    border-color: oklch(from var(--button-border-color) calc(l * 0.95) c h);
    background: oklch(from var(--button-background) calc(l * 0.95) c h);
  }
}

.button--primary {
  --button-background: var(--button-background--primary);
  --button-border-color: var(--button-border-color--primary);
  --button-color: var(--button-color--primary);
}

.button--secondary {
  --button-background: var(--button-background--secondary);
  --button-border-color: var(--button-border-color--secondary);
  --button-color: var(--button-color--secondary);
}

.button--clear {
  --button-background: transparent;
  --button-border-color: transparent;
  --button-color: inherit;
  --button-font-family: inherit;
  --button-shadow: none;
}

.button--small {
  --button-font-size: var(--button-font-size--small);
  --button-padding: var(--button-padding--small);
}

/* ========= Components: Popovers ======== */

.popover:popover-open {
  background: #fff;
  border: solid 1px var(--popover-border-color);
  border-radius: var(--default-border-radius--rounded);
  box-shadow: var(--popover-shadow);
  display: block;
  inset: unset;
  margin: 0;
  margin-top: 4px;
  padding: 0;
  position: relative;
}

.dialog:popover-open, .dialog:open {
  background: #fff;
  border: solid 1px var(--popover-border-color);
  border-radius: var(--default-border-radius--rounded);
  box-shadow: var(--popover-shadow);
  display: block;
  max-height: 90vh;
  overflow: auto;
}

.basic-dropdown__menu {
  list-style-type: none;
  margin: 0;
  padding: var(--default-padding--sm) 0;

  & > li {
    padding: 0;

    &:hover {
      background: #0001;
    }

    & > button, & > [role="button"] {
      background: transparent;
      color: inherit;
      display: block;
      font-family: var(--button-font-family--default);
      padding: var(--button-padding--default);
      text-decoration: none;
      transition: background 0.2s ease;
    }
  }
}

/* ======== Components: Miscellaneous ======== */

.table {
  border-collapse: collapse;

  th, td {
    border: solid 1px var(--default-border-color);
    padding: var(--default-padding--sm);
  }

  th {
    background: #eee;
  }

  .table__message {
    opacity: 0.5;
    text-align: center;
  }
}

.section {
  padding: 1rem 2rem;
}

.permissions-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--default-padding--sm);
}

.permission-badge {
  --permission-badge-resource-color: #f9f9f9;
  --permission-badge-description-color: #eee;

  display: flex;
  flex-grow: 0;
  flex-shrink: 0;
}

.permission-badge__resource {
  background: var(--permission-badge-resource-color);
  border: solid 1px oklch(from var(--permission-badge-resource-color) calc(l * 0.8) c h);
  border-right: none;
  border-bottom-left-radius: var(--default-border-radius--rounded-sm);
  border-top-left-radius: var(--default-border-radius--rounded-sm);
  font-family: var(--default-font-family--data);
  font-size: 0.9rem;
  padding: var(--default-padding--xs);
}

.permission-badge__description {
  background: var(--permission-badge-description-color);
  border: solid 1px oklch(from var(--permission-badge-description-color) calc(l * 0.8) c h);
  border-bottom-right-radius: var(--default-border-radius--rounded-sm);
  border-top-right-radius: var(--default-border-radius--rounded-sm);
  font-family: var(--default-font-family--data);
  font-size: 0.9rem;
  padding: var(--default-padding--xs);
}

/* ======== Forms ======== */

.form__label {
  display: block;
  font-weight: 600;
  margin-top: var(--default-padding);
}

.form__input {
  display: block;
  margin-top: var(--default-padding--sm);
  font-family: var(--default-font-family--data);

  &:is(input[type="text"]) {
    border: solid 1px var(--default-border-color);
    border-radius: var(--default-border-radius--rounded);
    padding: 0.5rem;
  }
}

.form__buttons {
  display: flex;
  margin-top: var(--default-padding);

  &.form__buttons--justify-end {
    justify-content: end;
  }

  button {
    margin: 0 var(--default-padding--xs);

    &:first-child {
      margin-left: 0;
    }

    &:last-child {
      margin-right: 0;
    }
  }
}

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

.layout-with-sidebar, .layout-with-toolbar {
  height: 100vh;
  width: 100vw;
  display: grid;
  grid-template:
    'banner banner' max-content
    'sidebar toolbar' 64px
    'sidebar main' 1fr / max-content 1fr;

  .banner {
    grid-area: banner;
  }

  .toolbar {
    grid-area: toolbar;
  }

  .sidebar {
    grid-area: sidebar;
  }

  main {
    grid-area: main;
    overflow: auto;
  }
}

.banner {
  background: oklch(from var(--accent-color) 0.5 0.08 calc(h + 135));
  color: #fff;
  padding: 8px;
  text-align: center;

  a {
    color: oklch(from var(--a-color) 0.9 calc(c * 0.3) h);
  }

  .ti {
    position: relative;
    top: 0.05rem;
  }
}

.sidebar {
  width: 15rem;
  max-height: 100vh;
  overflow: auto;
  border-right: solid 1px var(--default-border-color);
}

.toolbar {
  align-items: center;
  border-bottom: solid 1px var(--default-border-color);
  display: grid;
  grid-template: 'utilities user' 1fr / 1fr max-content;

  .toolbar__page-actions {
    align-items: center;
    display: flex;
    gap: 12px;
    grid-area: utilities;
    justify-content: flex-start;
    padding: 0 12px;
  }

  .toolbar__user {
    align-items: center;
    display: flex;
    gap: 12px;
    grid-area: user;
    justify-content: flex-end;
    padding: 0 12px;

    basic-dropdown {
      --button-background: var(--button-background--secondary);
      --button-border-color: var(--button-border-color--secondary);
      --button-color: var(--button-color--secondary);
    }
  }
}

/* ======== Workspace Nav ======== */

.workspace-nav {
  padding: 16px;

  h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  h3 {
    font-size: 1.125rem;
  }

  h4, h5, h6 {
    font-size: 1rem;
  }

  basic-dropdown {
    --button-background: var(--button-background--secondary);
    --button-border-color: var(--button-border-color--secondary);
    --button-color: var(--button-color--secondary);
    --button-font-size: var(--button-font-size--small);
    --button-padding: var(--button-padding--small);
  }

  .workspace-nav__section {
    margin-top: var(--default-padding);
  }

  .workspace-nav__menu {
    list-style-type: none;
    padding: var(--default-padding--xs) 0;
    margin: 0;
  }

  .workspace-nav__heading {
    align-items: center;
    display: flex;
    font-size: inherit;
    justify-content: space-between;
    padding: var(--default-padding--sm);
    padding-bottom: 0;
  }

  .workspace-nav__menu-item {
    display: block;
    margin-left: var(--default-padding--sm);
    padding: 0;
  }

  .workspace-nav__menu-leaf {
    align-items: center;
    border-radius: var(--default-border-radius--rounded-sm);
    display: flex;
    justify-content: space-between;
    padding: var(--default-padding--xs) var(--default-padding--sm);

    &.workspace-nav__menu-leaf--current, &:hover {
      background: #0001;
    }
  }

  .workspace-nav__menu-link {
    flex: 1;
    padding: var(--default-padding--sm) 0;
  }
}
