@import 'https://esm.sh/open-props@1.7.23/open-props.min.css';
@import 'https://esm.sh/open-props@1.7.23/normalize.min.css';

@import url('https://fonts.googleapis.com/css2?family=Cabin:ital,wght@0,400..700;1,400..700&display=swap');

:root {
  color-scheme: light;
  --editor-width: 60ch;
  --editor-first-letter-font-family: inherit;
  --editor-first-letter-font-size: 1em;
  --editor-first-letter-line-height: inherit;
  --editor-first-letter-font-weight: inherit;
  --editor-first-letter-color: inherit;
  --write-sidebar-width: clamp(16rem, 25vw, 20rem);
  --brand-light: var(--indigo-7);
  --text-1-light: var(--gray-12);
  --text-2-light: var(--gray-7);
  --surface-1-light: var(--gray-0);
  --surface-2-light: var(--gray-2);
  --surface-3-light: var(--gray-3);
  --surface-4-light: var(--gray-4);
  --surface-shadow-light: var(--gray-8-hsl);
  --shadow-strength-light: 2%;

  --brand-dark: var(--indigo-3);
  --text-1-dark: var(--gray-1);
  --text-2-dark: var(--gray-4);
  --surface-1-dark: var(--gray-9);
  --surface-2-dark: var(--gray-8);
  --surface-3-dark: var(--gray-7);
  --surface-4-dark: var(--gray-6);
  --surface-shadow-dark: var(--gray-12-hsl);
  --shadow-strength-dark: 80%;

    /* dim */
  --brand-dim: var(--orange-4);
  --text-1-dim: var(--gray-3);
  --text-2-dim: var(--gray-4);
  --surface-1-dim: var(--gray-8);
  --surface-2-dim: var(--gray-7);
  --surface-3-dim: var(--gray-6);
  --surface-4-dim: var(--gray-5);
  --surface-shadow-dim: var(--gray-9-hsl);
  --shadow-strength-dim: 20%;

  /* set defaults */
  --brand: var(--brand-light);
  --text-1: var(--text-1-light);
  --text-2: var(--text-2-light);
  --surface-1: var(--surface-1-light);
  --surface-2: var(--surface-2-light);
  --surface-3: var(--surface-3-light);
  --surface-4: var(--surface-4-light);
  --surface-shadow: var(--surface-shadow-light);
  --shadow-strength: var(--shadow-strength-light);

  --surface-app: var(--surface-1);
  --surface-raised: var(--surface-2);
  --surface-raised-hover: var(--surface-3);
  --surface-overlay: color-mix(in oklab, var(--surface-2) 84%, var(--surface-4) 16%);
  --brand-muted: color-mix(in oklab, var(--brand), var(--surface-1) 50%);
  --border-subtle: color-mix(in oklab, var(--text-1) 18%, var(--surface-1) 82%);
  --border-muted: color-mix(in oklab, var(--text-1) 12%, var(--surface-1) 88%);
  --focus-ring: color-mix(in oklab, var(--text-1) 34%, var(--surface-1) 66%);
  --text-muted: var(--text-2);
}

html[color-scheme="dark"] {
  color-scheme: dark;
  --brand: var(--brand-dark);
  --text-1: var(--text-1-dark);
  --text-2: var(--text-2-dark);
  --surface-1: var(--surface-1-dark);
  --surface-2: var(--surface-2-dark);
  --surface-3: var(--surface-3-dark);
  --surface-4: var(--surface-4-dark);
  --surface-shadow: var(--surface-shadow-dark);
  --shadow-strength: var(--shadow-strength-dark);
}

html[color-scheme="dim"] {
  color-scheme: dark;
  --brand: var(--brand-dim);
  --text-1: var(--text-1-dim);
  --text-2: var(--text-2-dim);
  --surface-1: var(--surface-1-dim);
  --surface-2: var(--surface-2-dim);
  --surface-3: var(--surface-3-dim);
  --surface-4: var(--surface-4-dim);
  --surface-shadow: var(--surface-shadow-dim);
  --shadow-strength: var(--shadow-strength-dim);
}
/* Box sizing rules */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Prevent font size inflation */
html {
  background: var(--surface-app);
  color: var(--text-1, inherit);
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  font-family: "Cabin", sans-serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  font-variation-settings:
    "wdth" 100;
}

/* Remove default margin in favour of better control in authored CSS */
body, h1, h2, h3, h4, p,
figure, blockquote, dl, dd {
  margin-block-end: 0;
}

/* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */
ul[role='list'],
ol[role='list'] {
  list-style: none;
}

/* Set core body defaults */
body {
  background: var(--surface-app);
  color: var(--text-1, inherit);
  min-height: 100vh;
  line-height: 1.5;
}

/* Set shorter line heights on headings and interactive elements */
h1, h2, h3, h4,
button, input, label {
  line-height: 1.1;
}

/* Balance text wrapping on headings */
h1, h2,
h3, h4 {
  text-wrap: balance;
}

/* A elements that don't have a class get default styles */
a:not([class]) {
  text-decoration-skip-ink: auto;
  color: currentColor;
}

/* Make images easier to work with */
img,
picture {
  max-width: 100%;
  display: block;
}

/* Inherit fonts for inputs and buttons */
input, button,
textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* Make sure textareas without a rows attribute are not tiny */
textarea:not([rows]) {
  min-height: 10em;
}

/* Anything that has been anchored to should have extra scroll margin */
:target {
  scroll-margin-block: 5ex;
}

iconify-icon {
 display: inline-block;
 width: 1em;
 height: 1em;
}

.header {
  padding-left: 1rem;
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;

  > h1 {
    font-size: 1.5rem;
  }
}

.shell {
  display: flex;
  --docs-pane-default: min(24rem, 45vw);

  > router-view {
    min-width: 0;
    overflow: auto;
    resize: none;
  }

  > .aside-rail {
    flex: 0 0 0;
    min-width: 0;
    opacity: 0;
    pointer-events: none;
    position: sticky;
    top: 10px;
    height: calc(100vh - 1rem);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: hidden;
  }

  > .aside-rail > aside {
    display: none;
    min-height: 0;
    border-radius: 0.35rem;
    box-shadow: inset 0 0 0 1px var(--border-muted);
    overflow: hidden;
    background: var(--surface-raised);
  }

  > .aside-rail > aside > router-view {
    height: 100%;
    overflow: auto;
  }

  > .aside-rail > aside:has(> router-view:not(:empty)) {
    display: block;
    flex: 1 1 auto;
  }

  > .aside-rail:has(> aside.docs-aside > router-view:not(:empty)):has(> aside.me-aside > router-view:not(:empty)),
  > .aside-rail:has(> aside.docs-aside > router-view:not(:empty)):has(> aside.encryption-aside > router-view:not(:empty)),
  > .aside-rail:has(> aside.me-aside > router-view:not(:empty)):has(> aside.encryption-aside > router-view:not(:empty))
    > aside:has(> router-view:not(:empty)) {
    flex: 1 1 0;
  }

  &:not(:has(> .aside-rail > aside > router-view:not(:empty))) > router-view {
    flex: 1;
  }

  &:has(> .aside-rail > aside > router-view:not(:empty)) {
    > router-view {
      flex: 0 0 auto;
      resize: horizontal;
      width: max(24rem, calc(100% - var(--docs-pane-default)));
      max-width: 100%;
    }

    > .aside-rail {
      flex: 1 1 0;
      opacity: 1;
      pointer-events: auto;
      margin: 0.5rem;
      > aside {
        padding: 1rem;
      }
    }
  }
}

.page {
  overflow: auto;
  height: 90vh;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  margin: 0.5rem;
  align-items: flex-start;
  background: var(--surface-raised);
}

.home.page {
  /* https://www.joshwcomeau.com/gradient-generator/ */
  background-image: linear-gradient(60deg,
  hsl(214deg 100% 52%) 0%,
  hsl(221deg 100% 64%) 2%,
  hsl(223deg 100% 70%) 5%,
  hsl(222deg 100% 75%) 11%,
  hsl(220deg 100% 79%) 20%, 
  hsl(216deg 100% 82%) 40%,
  hsl(209deg 99% 86%) 83%,
  hsl(197deg 97% 89%) 100%
  );
  background-size: 100%;
  background-position: 0px;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  height: 100vh;
  margin: 0;
  border-radius: 0;

  > summary {
    background: color-mix(in oklab, var(--surface-1) 80%, transparent);
    border-radius: 5px;
  }

  > img {
    width: clamp(50vw, 400px, 90vw);
  }

  h1 {
    color: mintcream;
  }
}

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-group(router-view-root) {
    animation-duration: 260ms;
    animation-timing-function: ease;
  }

  ::view-transition-old(router-view-root) {
    animation: router-out 260ms ease both;
  }

  ::view-transition-new(router-view-root) {
    animation: router-in 260ms ease both;
  }

  ::view-transition-group(router-view-docs) {
    animation: none;
  }

  ::view-transition-old(router-view-docs) {
    animation: docs-fade-out 220ms ease both;
  }

  ::view-transition-new(router-view-docs) {
    animation: docs-fade-in 220ms ease both;
  }
}

@keyframes router-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes router-in {
  from { opacity: 0;}
  to { opacity: 1; }
}

@keyframes docs-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes docs-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.error-sheet {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-left: 0.4rem solid var(--focus-ring);
  border-radius: 0.5rem;
  margin-inline: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.75rem;

  > div {
    width: var(--editor-width);
    margin-inline: auto;
  }
}

.error-sheet[data-error-severity="warning"] {
  border-left-color: color-mix(in oklab, orange 65%, var(--text-1) 35%);
}

@media (max-width: 900px) {
  :root {
    --write-sidebar-width: min(20rem, 88vw);
  }
}

.error-sheet[data-error-severity="error"] {
  border-left-color: color-mix(in oklab, red 58%, var(--text-1) 42%);
}

.error-sheet[data-error-severity="fatal"] {
  border-left-color: color-mix(in oklab, red 72%, black 28%);
}

.error-sheet-header {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;

  > h2 {
    font-size: 1rem;
    margin: 0;
  }

  > p {
    color: var(--text-muted);
    margin: 0;
  }
}

.error-meta {
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.84rem;
  gap: 0.4rem 1rem;
  margin: 0.5rem 0 0;
}

.error-debug {
  margin-top: 0.5rem;

  > pre {
    background: var(--surface-overlay);
    border-radius: 0.35rem;
    margin: 0.4rem 0 0;
    max-height: 12rem;
    overflow: auto;
    padding: 0.5rem;
    white-space: pre-wrap;
  }
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.error-actions > button,
.error-actions > a {
  background: var(--surface-overlay);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  font-size: 0.84rem;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  text-decoration: none;
}

:where(textarea,select,input:not([type=button],[type=submit],[type=reset])) {
  background-color: var(--surface-1);
}
