/*

  Index

  1. Custom properties
  2. Generic
  3. Main content
  4. Typography
  5. Lists
  6. Icons
  7. Buttons
  8. Form elements
  9. Navigation
  10. Progress bar
  11. Popovers
  12. Info blocks
  13. App banners
  14. Stories
  15. Translation popover
  16. Settings
  17. Voice & language selection
  18. Loading state
  19. Developer controls

*/


/* 1. Custom properties
---------------------------------------------------------------------------- */
:root{
  --accent-yellow: #ecbf4b;

  --shade-subtle: rgba(0,0,0,.01);
  --shade-default: rgba(0,0,0,.03);
  --shade-strong: rgba(0,0,0,.08);

  --background-primary: #ffffff;
  --background-secondary: #fafafa;
  --background-popover: #ffffff;
  --background-yellow: #faf3e1;
  --background-velvet: #eedfe7;

  --text-primary: rgba(0,0,0,1);
  --text-secondary: rgba(0,0,0,.84);
  --text-tertiary: rgba(0,0,0,.55);
  --text-velvet: #6c003e;

  --icon-default: rgba(0,0,0,.64);

  --border-subtle: rgba(0,0,0,.08);
  --border-default: rgba(0,0,0,.12);
  --border-strong: rgba(0,0,0,.16);

  --page-width: 34rem;

  --font-size: 100%;
  --line-height: 1.5;
}

.show-settings,
.started.show-translation{
  --background-primary: var(--background-secondary);
}



/* 2. Generic
---------------------------------------------------------------------------- */
*,
*::after,
*::before{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

*:focus-visible{
  outline-color: var(--accent-yellow);
}

html{
  scroll-behavior: smooth;
  cursor: default;
}

body{
  background-color: var(--background-primary);
  transition: opacity linear .3s; /* to animate html.loading */
}

[hidden],
.ios .hide-on-ios,
body:not(.ios) .ios-only,
.no-js .js-only,
.js .no-js-only{
  display: none !important;
}

@media screen and (display-mode: standalone){
  .hide-on-standalone{
    display: none !important;
  }
}

.visually-hidden{
  position: absolute !important;
  clip: rect(1px, 1px, 1px, 1px) !important;
  -webkit-clip-path: inset(50%) !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  height: 1px !important;
  width: 1px !important;
  padding: 0 !important;
  border: 0 !important;
}

hr{
  border-width: 0.0625rem 0 0 0;
  border-color: var(--border-subtle);
  margin-block: 1.5rem;
}



/* 3. Main content
---------------------------------------------------------------------------- */
main{
  position: relative;
  max-width: var(--page-width);
  margin: 2rem auto;
  padding: 0 1rem 12rem; /* make sure content doesn't dissapear behind nav */
}

@media screen and (min-width: 561px){
  main{
    margin-block-start: 3rem;
  }
}

@media screen and (min-width: 641px){
  main{
    margin-block-start: 4.5rem;
  }
}



/* 4. Typography
---------------------------------------------------------------------------- */
html{
  font: 100% / 1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Helvetica Neue", Arial, sans-serif;
  color: var(--text-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1{
  font-size: 1.125rem;
  line-height: 1.5rem;
  color: var(--text-secondary);
}

h2{
  font-size: 1rem;
  line-height: 1.25rem;
  color: var(--text-secondary);
  padding-block-end: .25rem;
  margin-block-start: 1.25rem;
}

h3{
  font-size: .9375rem;
  line-height: 1.25rem;
  color: var(--text-secondary);
}

h1 + p{
  margin-block-start: .25rem;
}

a{
  color: var(--text-secondary);
}

a:visited{
  color: #6C003E;
}

dt,
label,
small,
.small-text,
.story.dialogue [data-name]::before{
  font-size: .875rem;
  line-height: 1rem;
  color: var(--text-tertiary);
}

.text-align-right{
  text-align: right;
}

[data-sentence]{
  transition: color .2s;
}

[data-sentence]:focus{
  outline-color: var(--accent-yellow);
}

[data-sentence][aria-current]{
  color: var(--text-primary);
}

body.started [data-sentence]:not([aria-current]){
  color: var(--text-tertiary);
}

body.started .story.dialogue p:has([aria-current]){
  background-color: var(--background-yellow);
}

body.started .story.dialogue p:not(:has([aria-current])){
  background-color: var(--shade-default);
}



/* 5. Lists
---------------------------------------------------------------------------- */
ul,
ol{
  padding-inline-start: 1.5rem;
}

dl{
  user-select: none;
}

dl dt{
  padding-block-end: .25rem;
}

.list,
.styled-list{
  list-style: none;
  padding: 0;
  margin-block: 0 1.5rem;
}

.list a{
  display: block;
  padding-block: .5rem;
  text-decoration: none;
}

.list li:first-of-type a{
  padding-block-start: 1rem;
}

.list li:last-of-type a{
  padding-block-end: 1rem;
}

.list a p{
  text-decoration: underline;
}

.list a:hover p{
  text-decoration: none;
}



/* 6. Icons
---------------------------------------------------------------------------- */
.icon{
  vertical-align: bottom;
}

.icon-sprite path,
.icon-sprite .stroke{
  stroke: currentColor;
}

.icon-sprite rect,
.icon-sprite .fill{
  fill: currentColor;
}

.icon-sprite rect,
.icon-sprite .no-stroke{
  stroke: none;
}

.icon-sprite path,
.icon-sprite .no-fill{
  fill: none;
}

.icon-sprite .round{
  stroke-linecap: round;
  stroke-linejoin: round;
}



/* 7. Buttons
---------------------------------------------------------------------------- */


  /* 7.1 Generic ----------------------------------------------------------- */
  button,
  .button{
    display: inline-block;
    padding: 1.25rem;
    padding: calc(1.25rem - 1px); /* exclude border */
    border: 1px solid var(--border-default);
    border-radius: .75rem;

    font: inherit;
    line-height: 1.5rem;
    text-align: center;
    color: var(--text-primary);
    white-space: nowrap;

    background-color: var(--background-popover);
    box-shadow: inset .125rem -.25rem .5rem rgba(0, 0, 0, 0.01);
  }

  @media screen and (max-width: 370px){
    button,
    .button{
      padding: .75rem;
      padding: calc(.75rem - 1px); /* exclude border */
    }
  }

  @media (hover: hover) {
    button:hover:not([disabled]),
    .button:hover:not([disabled]){
      filter: brightness(.98);
    }
  }

  button:active:not([disabled]),
  button.pressed:not([disabled]),
  .button:active:not([disabled]),
  .button.pressed:not([disabled]){
    filter: brightness(.97);
    box-shadow: inset .125rem .25rem .5rem rgba(0, 0, 0, 0.02);
  }

  button:disabled{
    opacity: .3;
    cursor: not-allowed;
  }


  /* 7.2 Primary button -------------------------------------------------- */
  button.primary{
    border-color: transparent;
    color: var(--text-velvet);
    background-color: var(--background-yellow);
  }


  /* 7.3 Quiet button ------------------------------------------------------ */
  button.quiet,
  .button.quiet{
    border-color: transparent;
    color: var(--text-secondary);
    background-color: transparent;
    box-shadow: none;
  }

  @media (hover: hover) {
    button.quiet:hover,
    .button.quiet:hover{
      background-color: var(--background-primary);
    }
  }


  /* 7.4 Small button ------------------------------------------------------ */
  button.small,
  .button.small{
    padding: .75rem;
    padding: calc(.75rem - 1px); /* exclude border */
  }

  @media screen and (max-width: 370px){
    button.small,
    .button.small{
      padding: .5rem .75rem;
      padding: calc(.5rem - 1px) calc(.75rem - 1px); /* exclude border */
      border-radius: .5rem;
    }
  }

  /* 7.5 Icon only --------------------------------------------------------- */
  button.icon-only,
  .button.icon-only{
    line-height: 0;
    color: var(--icon-default);
  }

  /* 7.5 Icon only --------------------------------------------------------- */
  button.rounded,
  .button.rounded{
    border-radius: 50%;
  }

  /* 7.6 Play and pause ------------------------------------------------------ */
  button.icon-only.play,
  button.icon-only.pause{
    color: var(--accent-yellow);
  }

  body.started:not(.paused) .play,
  body:not(.started.paused) .pause,
  body.paused .pause{
    display: none;
  }

  body.started:not(.paused) .pause{
    display: inline-block;
  }



/* 8. Form elements
---------------------------------------------------------------------------- */
label{
  display: block;
  padding-block-end: .25rem;
  user-select: none;
}

input:not([type=range]),
textarea{
  font: inherit;
  padding: .75rem;
  padding: calc(.75rem - 1px); /* exclude border */
  border: 1px solid var(--border-subtle);
  border-radius: .75rem;
}

@media (hover: hover) {
  input:hover,
  textarea:hover{
    border-color: var(--border-default);
  }
}

input:focus,
textarea:focus{
  outline: none;
  border-color: var(--border-strong);
  box-shadow: inset 0 .25rem .5rem 0 rgba(0, 0, 0, .024);
}

select{
  appearance: none;
  border-radius: .25rem;
  font: inherit;
  color: var(--text-primary);
}

select.quiet{
  padding: 0;
  border: none;
  background-color: var(--background-primary);
}

select + .icon{
  width: 1rem;
  height: 1rem;
  vertical-align: top;
  margin-block-start: .25rem;
}

/*input[type=range]{
  appearance: none;
  accent-color: var(--accent-yellow);
  height: .25rem;
  border-radius: .125rem;
  background: var(--shade-strong);
  cursor: col-resize;
}

input[type=range]::-webkit-slider-thumb{
  -webkit-appearance: none;
  cursor: ew-resize;
  width: 19px;
  height: 19px;
  background: var(--background-popover);
  box-shadow: 0px .25rem .5rem rgba(0, 0, 0, 0.04), 0px 0px 3px rgba(0, 0, 0, 0.24);
  border-radius: 50%;
}

input[type=range]::-webkit-slider-runnable-track,
input[type=range]::-moz-range-track,
input[type=range]::-ms-track{
  appearance: none;
  background: var(--shade-strong)!important;
}*/


/* 9. Navigation
---------------------------------------------------------------------------- */
nav{
  z-index: 3;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  max-width: var(--page-width);
  padding: 1rem;
  margin: 0 auto;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--background-primary);
  user-select: none;
}

.ios nav{
  padding-block-end: 3rem;
}



/* 10. Progress bar
---------------------------------------------------------------------------- */
progress{
  width: auto;
  height: .25rem;
  position: fixed;
  z-index: 4;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: transparent;
}

progress::-webkit-progress-bar{
  border-radius: 0;
  background-color: var(--shade-default);
}

progress::-webkit-progress-value{
  border-radius: 0;
  background-color: var(--accent-yellow);
}

progress::-moz-progress-bar{
  border-radius: 0;
  background-color: var(--accent-yellow);
}



/* 11. Popovers
---------------------------------------------------------------------------- */
[class*=popover]{
  background-color: var(--background-popover);
  filter:
    drop-shadow(0px .25rem .25rem rgba(0, 0, 0, 0.08))
    drop-shadow(0px .25rem .5rem rgba(0, 0, 0, 0.08))
    drop-shadow(0px 1.5rem 1.5rem rgba(0, 0, 0, 0.04));
  border-radius: 1rem;
}

[class*=popover].pointer::after{
  content: '';
  display: block;
  position: absolute;
  transform: rotate(45deg);
  width: 1rem;
  height: 1rem;
  background-color: var(--background-popover);
}

[class*=popover].pointer.top-right::after{
  top: -.5rem;
  right: 1.5rem;
}

[class*=popover].pointer.bottom-center::after{
  bottom: -.5rem;
  left: 50%;
  margin-left: -.5rem;
}



/* 12. Info Blocks
---------------------------------------------------------------------------- */
.info{
  display: block;
  background-color: var(--background-yellow);
  border-radius: .25rem;
  padding-inline: .75rem;
  padding-block: .5rem;
  margin-block: 1.5rem;
  font-size: .875rem;
  color: var(--text-tertiary);
}

.info.velvet{
  background-color: var(--background-velvet);
}



/* 13. App banners
---------------------------------------------------------------------------- */
@media screen and (display-mode: browser){
  body.ios{
    transition: padding-top ease-out .2s .1s;
  }

  body.ios:not(.hide-app-banner){
    padding-top: 6rem;
  }

  body.show-install-explanation{
    --background-primary: var(--background-secondary);
  }

  .add-app-popover{
    position: fixed;
    right: 0;
    top: 1rem;
    left: 0;
    display: grid;
    grid-template-columns: auto 2.5rem 1fr auto;
    align-items: center;
    width: fit-content;
    min-width: 18rem;
    padding-inline: 0 .5rem;
    margin-block: 0 2.5rem;
    margin-inline: auto;
    border-radius: 1rem;
    transition: transform ease-out .2s;
    user-select: none;
  }

  .hide-app-banner .add-app-popover{
    transform: translateY(-8rem);
  }

  .show-install-explanation .add-app-popover{
    opacity: .5;
  }

  .add-app-popover .close-button{
    padding-inline: .5rem .25rem;
    border-radius: 1rem 0 0 1rem;
  }

  .add-app-popover .app-icon{
    border-radius: .5rem;
  }

  .add-app-popover .text{
    flex-grow: 1;
    padding-block: .5rem;
    margin-inline: .75rem;
    line-height: 1.2;
  }

  .explanation-popover{
    position: fixed;
    right: .75rem;
    bottom: 1rem;
    left: .75rem;
    transform: translateY(-1.5rem);
    opacity: 0;
    transition:
      opacity ease-out .1s,
      transform ease-out .1s;
    max-width: fit-content;
    margin: 0 auto;
    padding: 1rem;
    user-select: none;
  }

  .show-install-explanation .explanation-popover{
    transform: none;
    opacity: 1;
  }

  .explanation-popover .description{
    display: block;
    margin-block: 0.25rem .5rem;
  }
}

/* Eventually support beyond iOS @media (hover:none) and (pointer:coarse) {} */



/* 14. Stories
---------------------------------------------------------------------------- */
.story p{
  margin: 1.25rem 0;
  margin: calc(var(--line-height) * 0.8333rem) 0;
  font-size: var(--font-size);
  line-height: var(--line-height);
}

.story.dialogue p{
  display: inline-block;
  max-width: 24rem;
  padding: .75rem 1rem;
  margin-inline-start: -1rem;
  margin-block-end: 0;
  border-radius: .75rem .75rem .75rem 0;
  background-color: var(--shade-default);
}

.story.dialogue .right{
  text-align: right;
}

.story.dialogue .right p{
  margin-inline-end: -1rem;
  border-radius: .75rem .75rem 0 .75rem;
}

.story.dialogue .left + .left p,
.story.dialogue .right + .right p{
  margin-block-start: .25rem;
}

.story.dialogue [data-name]::before{
  content: attr(data-name);
  display: block;
  margin-block-end: 0.125rem;
  color: var(--text-tertiary);
}

.story.dialogue .left + .left [data-name]::before,
.story.dialogue .right + .right [data-name]::before{
  display: none;
}

@media screen and (max-width: 30rem){
  .story.dialogue p{
    max-width: 75%;
  }

  .story.dialogue p{
    border-radius: 0 .75rem .75rem 0;
  }

  .story.dialogue .right p{
    border-radius: .75rem 0 0 .75rem;
  }
}



/* 15. Translation popover
---------------------------------------------------------------------------- */
.translation-popover{
  z-index: 2;
  position: absolute;
  top: 1rem;
  right: 0;
  left: 0;
  width: fit-content;
  max-width: calc(var(--page-width) - 1rem);
  min-width: 6rem;
  padding: 1rem 1rem 1.25rem;
  margin: 0 auto;
  overflow: visible; /* for the close button to be visible */
  font-size: var(--font-size);
  line-height: var(--line-height);
  transition: transform .4s cubic-bezier(0,1.3,.8,1);
}

.translation-popover [data-translation-text]{
  position: relative;
  z-index: 1; /* So the button's background doesn't cover the text */
}

body.show-translation [data-show-translation],
body.show-translation:not(.started) .translation-popover,
body:not(.show-translation) [data-translation-text],
body:not(.show-translation) [data-hide-translation]{
  display: none;
}

body:not(.started.show-translation) .translation-popover{
  position: fixed;
  top: auto;
  bottom: 8rem;
  padding: 0;
  transform: none!important;
}

body.ios:not(.started.show-translation) .translation-popover{
  bottom: 11rem;
}

.translation-popover button[data-hide-translation]{
  color: var(--text-secondary);
  position: absolute;
  bottom: -1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--background-popover);
}

.translation-popover button[data-hide-translation]::before{
  background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODAiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCA4MCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTIxLjEzNzQgMTQuODQwOEMyNS41MzIxIDIwLjQxODcgMzIuMzQ3OCAyNCA0MCAyNEM0Ny42NTIyIDI0IDU0LjQ2NzkgMjAuNDE4NyA1OC44NjI2IDE0Ljg0MDlDNjQuMzMxMyA3Ljg5OTc5IDcxLjE2MzQgMCA4MCAwSDBDOC44MzY1NiAwIDE1LjY2ODcgNy44OTk3OCAyMS4xMzc0IDE0Ljg0MDhaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K)
}

.translation-popover button .curve{
  z-index: -1;
  position: absolute;
  bottom: -1px;
  left: -1rem;
  width: 5rem;
  height: 1.5rem;
  color: var(--background-popover);
  pointer-events: none;
}



/* 16. Settings
---------------------------------------------------------------------------- */
.settings-popover{
  z-index: 5;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  max-width: var(--page-width);
  padding: 1.25rem 1rem 1rem;
  margin: 0 auto;
  border-radius: 1rem 1rem 0 0;
  user-select: none;
}

.settings-popover input[type=range]{
  width: 100%;
}



/* 17. Voice & language selection
---------------------------------------------------------------------------- */
.selection-row{
  display: flex;
  gap: 1.5rem;
  margin-block: 1.5rem;
}

[data-duration]{
  font-variant-numeric: tabular-nums;
}



/* 18. Loading state
---------------------------------------------------------------------------- */
html.loading{
  cursor: progress;
}

html.loading body{
  opacity: .3;
  overflow: hidden;
  user-select: none;
  pointer-events: none;
  transition: opacity linear 0s;
}



/* 19. Developer controls
---------------------------------------------------------------------------- */
.developer-controls{
  grid-column: 1 / span 3;
  display: none;
  grid-template-columns: auto 1fr auto;
  grid-gap: 1rem;
  margin-block-start: 1rem;
  text-align: center;
}

.devmode .developer-controls{
  display: grid;
}

.developer-controls input{
  text-align: center;
}