/*

  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. Voice selection
  14. Loading state
  15. Developer controls

*/


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

  --shade-default: rgba(0,0,0,.02);
  --shade-dark: 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: 56ch;

  --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{
  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;
}

ul{
  padding-inline-start: 1.5rem;
}

dl{
  user-select: none;
}

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

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 0;
}

main .story{
  padding-block-end: 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: var(--font-size) / var(--line-height) -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);
}

main > h1{
  padding-block-end: .25rem;
}

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

.story p{
  margin: 1.25rem 0;
}

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

a:visited{
  color: #6C003E;
}

small,
dt,
.small,
label{
  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);
}



/* 5. Lists
---------------------------------------------------------------------------- */
.list{
  list-style: none;
  padding: 0;
  margin-block: 0 1.5rem;
}

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

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

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

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

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



/* 6. Icons
---------------------------------------------------------------------------- */
.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
---------------------------------------------------------------------------- */
button,
.button-style{
  display: inline-block;
  border: 1px solid transparent;
  padding: 1.25rem;
  padding: calc(1.25rem - 1px); /* exclude border */
  background: var(--background-primary);
  border-radius: .75rem;
  font: inherit;
  color: var(--text-primary);
  text-align: center;
}

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

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

button:active:not([disabled]),
.button-style:active:not([disabled]){
  filter: brightness(.97);
}

button:disabled{
  opacity: .3;
}

button.secondary{
  border-color: #e8e8e8;
  box-shadow: inset .125rem -.25rem .5rem rgba(0, 0, 0, 0.01);
}

button.secondary:active,
button.secondary.pressed{
  box-shadow: inset .125rem .25rem .5rem rgba(0, 0, 0, 0.02);
}

button.quiet{
  color: var(--text-secondary);
}

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

button.icon-only,
.button-style.icon-only{
  line-height: 0;
  border-radius: 50%;
  color: var(--icon-default);
}

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-dark);
  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-dark)!important;
}*/


/* 9. Navigation
---------------------------------------------------------------------------- */
nav{
  z-index: 3;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  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;
}

.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 */
  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;
}


/* 12. Info Blocks
---------------------------------------------------------------------------- */
p.info{
  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);
}


/* X. 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%;
}



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

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



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

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



/* 15. 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;
}