/* All styles in this sheet are needed on page load */

/* Layout */

html,
body {
    margin: 0;
    display: flex;
    flex-direction: column;
    width: 100vw;
    overflow-x: hidden;
    overscroll-behavior: none;
    overflow-y: hidden;
    /* Only allow selection on message and pair key */
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    transition: color 300ms;
}

body {
    height: 100%;
}

html {
    height: 100%;
}

.fw {
    width: 100%;
}

.p1 {
    padding: 10px;
}

.row-reverse {
    display: flex;
    flex-direction: row-reverse;
}

.space-between {
    justify-content: space-between;
}

.row {
    display: flex;
    flex-direction: row;
}

.column {
    display: flex;
    flex-direction: column;
}

.center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.grow {
    flex-grow: 1;
}

.full {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.pointer {
    cursor: pointer;
}

header {
    position: absolute;
    align-items: baseline;
    padding: 8px 12px;
    box-sizing: border-box;
    width: 100vw;
    z-index: 20;
    top: 0;
    right: 0;
}

header > * {
    margin-left: 4px;
    margin-right: 4px;
}

header > div {
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    touch-action: manipulation;
}

header > div .icon-button {
    height: 40px;
    transition: all 300ms;
}

header > div > div {
    display: flex;
    flex-direction: column;
}

header > div:not(:hover) .icon-button:not(.selected) {
    height: 0;
    opacity: 0;
}

#theme-wrapper:hover::before {
    border-radius: 20px;
    background: currentColor;
    opacity: 0.1;
    transition: opacity 300ms;
    content: '';
    position: absolute;
    width: 40px;
    top: 0;
    bottom: 0;
    margin-top: 8px;
    margin-bottom: 8px;
}

header > div:hover .icon-button.selected::before {
    opacity: 0.1;
}

@media (pointer: coarse) {
    header > div:hover .icon-button.selected:hover::before {
        opacity: 0.2;
    }

    header > div .icon-button:not(.selected) {
        height: 0;
        opacity: 0;
        pointer-events: none;
    }

    header > div > div {
        flex-direction: column-reverse;
    }
}

[hidden] {
    display: none !important;
}


/* Typography */

@font-face {
    font-family: "Open Sans";
    src: url('../fonts/OpenSans/static/OpenSans-Medium.ttf') format('truetype');
}

body {
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-variant-ligatures: common-ligatures;
    font-kerning: normal;
}

h1 {
    font-size: 34px;
    font-weight: 400;
    letter-spacing: -.01em;
    line-height: 40px;
    margin: 0 0 4px;
}

h2 {
    font-size: 24px;
    font-weight: 400;
    letter-spacing: -.012em;
    line-height: 32px;
    color: var(--primary-color);}

h3 {
    font-size: 20px;
    font-weight: 500;
    margin: 16px 0;
    color: var(--primary-color);
}

.font-subheading {
    font-size: 14px;
    font-weight: 400;
    line-height: 18px;
    word-break: normal;
}

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

.font-body1,
body {
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
}

.font-body2 {
    font-size: 12px;
    line-height: 18px;
}

a,
.icon-button {
    text-decoration: none;
    color: currentColor;
    cursor: pointer;
}

input {
    cursor: pointer;
}

input[type="checkbox"] {
    min-width: 13px;
}

x-noscript {
    background: var(--primary-color);
    color: white;
    z-index: 2;
}


/* Icons */

.icon {
    width: var(--icon-size);
    height: var(--icon-size);
    fill: currentColor;
}



/* Shadows */

[shadow="1"] {
    box-shadow: 0 3px 4px 0 rgba(0, 0, 0, 0.14),
        0 1px 8px 0 rgba(0, 0, 0, 0.12),
        0 3px 3px -2px rgba(0, 0, 0, 0.4);
}

[shadow="2"] {
    box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14),
        0 1px 10px 0 rgba(0, 0, 0, 0.12),
        0 2px 4px -1px rgba(0, 0, 0, 0.4);
}

.overflowing {
    background:
        /* Shadow covers */
            linear-gradient(rgb(var(--shadow-color-cover-rgb)) 30%, rgba(var(--shadow-color-cover-rgb), 0)),
            linear-gradient(rgba(var(--shadow-color-cover-rgb), 0), rgb(var(--shadow-color-cover-rgb)) 70%) 0 100%,
                /* Shadows */
            radial-gradient(farthest-side at 50% 0, rgba(var(--shadow-color-rgb), .2), rgba(var(--shadow-color-rgb), 0)),
            radial-gradient(farthest-side at 50% 100%, rgba(var(--shadow-color-rgb), .2), rgba(var(--shadow-color-rgb), 0))
            0 100%;
    background-repeat: no-repeat;
    background-size: 100% 60px, 100% 60px, 100% 24px, 100% 24px;
    background-attachment: local, local, scroll, scroll;
}


/* Animations */

@keyframes fade-in {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

#center {
    position: relative;
    display: flex;
    margin-top: 56px;
    flex-direction: column-reverse;
    flex-grow: 1;
    justify-content: space-around;
    align-items: center;
    overflow-x: hidden;
    overflow-y: scroll;
    overscroll-behavior-x: none;
}


/* Peers  */

#x-peers-filler {
    display: flex;
    flex-grow: 1;
}

x-peers {
    position: relative;
    display: flex;
    flex-flow: row wrap;
    flex-grow: 1;
    align-items: start !important;
    justify-content: center;

    z-index: 2;
    transition: background-color 0.5s ease;
    overflow-y: scroll;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    scrollbar-width: none;

    --peers-per-row: 6; /* default if browser does not support :has selector */
    --x-peers-width: min(100vw, calc(var(--peers-per-row) * (var(--peer-width) + 25px) - 16px));
    width: var(--x-peers-width);
    margin-right: 20px;
    margin-left: 20px;
}

/* Empty Peers List */

x-no-peers {
    display: flex;
    flex-direction: column;
    padding: 8px;
    height: 137px;
    text-align: center;
}

x-no-peers h2,
x-no-peers a {
    color: var(--primary-color);
    margin-bottom: 5px;
}

x-peers:not(:empty)+x-no-peers {
    display: none;
}

x-no-peers::before {
    color: var(--primary-color);
    font-size: 24px;
    font-weight: 400;
    letter-spacing: -.012em;
    line-height: 32px;
}

x-no-peers[drop-bg]::before {
    content: attr(data-drop-bg);
}

x-no-peers[drop-bg] * {
    display: none;
}

/* Footer */

footer {
    position: relative;
    z-index: 2;
    align-items: center;
    text-align: center;
    cursor: default;
    margin: auto 5px 5px;
}

footer .logo {
    --icon-size: 80px;
    margin-bottom: 8px;
    color: var(--primary-color);
    margin-top: -10px;
}

.discovery-wrapper {
    font-size: 14px;
    margin: 15px auto auto;
    border: 2px solid var(--border-color);
    padding: 2px;
    background-color: rgb(var(--bg-color));
    transition: background-color 0.5s ease;
    min-height: 24px;
}

.discovery-wrapper.column {
    border-radius: 16px;
}

.discovery-wrapper.row {
    border-radius: 12px;
}

/*You can be discovered wrapper*/
.discovery-wrapper > div:first-of-type {
    padding-left: 4px;
    padding-right: 4px;
}


.discovery-wrapper .badge {
    word-break: keep-all;
    margin: 2px;
}

.badge {
    border-radius: 0.4rem;
    padding-right: 0.3rem;
    padding-left: 0.3em;
    background-color: var(--badge-color);
    color: white;
    white-space: nowrap;
}

.badge-gradient {
    background-image: linear-gradient(180deg, color-mix(in srgb, var(--badge-color) 80%, white) 0%, var(--badge-color) 50%);
}

.badge-room-ip {
    --badge-color: var(--primary-color);
}

.badge-room-secret {
    --badge-color: var(--paired-device-color);
}

.badge-room-public-id {
    --badge-color: var(--public-room-color);
}

.known-as-wrapper {
    font-size: 16px; /* prevents auto-zoom on edit */
}

#display-name {
    position: relative;
    display: inline-block;
    text-align: left;
    border: none;
    outline: none;
    max-width: 15em;
    text-overflow: ellipsis;
    cursor: text;
    margin-bottom: -6px;
    padding-bottom: 0.1rem;
    border-radius: 1.3rem/30%;
    border-right: solid 1rem transparent;
    border-left: solid 1rem transparent;
    background-clip: padding-box;
    overflow: hidden;
    z-index: 1;
}

#edit-pen {
    width: 1rem;
    height: 1rem;
    margin-bottom: -2px;
    position: relative;
}

html:not([dir="rtl"]) #display-name,
html:not([dir="rtl"]) #edit-pen {
    margin-left: -1rem;
}

html[dir="rtl"] #display-name,
html[dir="rtl"] #edit-pen {
    margin-right: -1rem;
}

html[dir="rtl"] #edit-pen {
    transform: rotateY(180deg);
}

/* Dialogs needed on page load */
x-dialog:not([show]) x-background {
    opacity: 0;
}

/* Button */

.btn {
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    padding: 2px 16px 0;
    box-sizing: border-box;
    font-size: 14px;
    line-height: 24px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    background: inherit;
    color: var(--accent-color);
    overflow: hidden;
}

.btn[disabled] {
    color: var(--btn-disabled-color);
    cursor: not-allowed;
}


.btn,
.icon-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    touch-action: manipulation;
    border: none;
    outline: none;
}

.btn:before,
.icon-button:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    background-color: var(--accent-color);
    transition: opacity 300ms;
}

.btn:not([disabled]):hover:before,
.icon-button:hover:before {
    opacity: 0.1;
}

.btn[selected],
.icon-button[selected] {
    opacity: 0.1;
}

.btn:focus:before,
.icon-button:focus:before {
    opacity: 0.2;
}

.btn-rounded {
    border-radius: 12px;
}

.btn-grey {
    background-color: var(--bg-color-secondary);
}

button::-moz-focus-inner {
    border: 0;
}


/* Icon Button */
.icon-button {
    width: 40px;
    height: 40px;
}

.icon-button:before {
    border-radius: 50%;
}


/* Info Animation */

#about {
    color: white;
    z-index: 32;
    overflow: hidden;
    pointer-events: none;
    text-align: center;
}

#about header {
    z-index: 1;
}

#about:not(:target) header {
    transition-delay: 400ms;
}

#about:target header {
    transition-delay: 100ms;
}

#about > * {
    transition: opacity 300ms ease 300ms;
    will-change: opacity;
    pointer-events: all;
}

#about:not(:target) > header,
#about:not(:target) > section {
    opacity: 0;
    pointer-events: none;
    transition-delay: 0s;
}

#about .logo {
    --icon-size: 96px;
}

#about .title-wrapper {
    display: flex;
    align-items: baseline;
}

#about .title-wrapper > div {
    margin-left: 0.4em;
}

#about x-background {
    position: absolute;
    --size: max(max(230vw, 230vh), calc(150vh + 150vw));
    --size-half: calc(var(--size)/2);
    top: calc(28px - var(--size-half));
    width: var(--size);
    height: var(--size);
    z-index: -1;
    background: var(--primary-color);
    background-image: radial-gradient(circle at calc(50% - 36px), var(--accent-color) 0%, color-mix(in srgb, var(--accent-color) 40%, black) 80%);
    --crop-size: 0px;
    clip-path: circle(var(--crop-size));
}

html:not([dir="rtl"]) #about x-background {
    right: calc(36px - var(--size-half));
}

html[dir="rtl"] #about x-background {
    left: calc(36px - var(--size-half));
}


/* Hack such that initial scale(0) isn't animated */
#about x-background {
    will-change: clip-path;
    transition: clip-path 800ms cubic-bezier(0.77, 0, 0.175, 1);
}

#about:target x-background {
    --crop-size: var(--size);
}

#about .row a {
    margin: 8px 8px -16px;
}

#about section {
    flex-grow: 1;
}

canvas.circles {
    width: 100vw;
    position: absolute;
    z-index: -10;
    top: 0;
    left: 0;
}

/* Generic placeholder */
[placeholder]:empty:before {
    content: attr(placeholder);
}

/* Toast */

.toast-container {
    padding: 0 8px 24px;
    overflow: hidden;
    pointer-events: none;
}

x-toast {
    position: absolute;
    min-height: 48px;
    top: 50px;
    width: 100%;
    max-width: 344px;
    background-color: rgb(var(--text-color));
    color: var(--dialog-bg-color);
    align-items: center;
    box-sizing: border-box;
    padding: 8px 24px;
    z-index: 40;
    transition: opacity 200ms, transform 300ms ease-out;
    cursor: default;
    line-height: 24px;
    border-radius: 12px;
    pointer-events: all;
}

x-toast:not([show]):not(:hover) {
    opacity: 0;
    transform: translateY(-100px);
}

/* Instructions */

x-instructions {
    position: relative;
    opacity: 0.5;
    text-align: center;
    margin-left: 10px;
    margin-right: 10px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: center;
}

x-instructions:not([drop-peer]):not([drop-bg]):before {
    content: attr(mobile);
}

x-instructions[drop-peer]:before {
    content: attr(data-drop-peer);
}

x-instructions[drop-bg]:not([drop-peer]):before {
    content: attr(data-drop-bg);
}

x-instructions p {
    display: none;
}

x-peers:empty~x-instructions {
    opacity: 0 !important;
}

@media (hover: none) and (pointer: coarse) {
    x-peer {
        transform: scale(0.95);
        padding: 4px;
    }
}

/* Prevent Cumulative Layout Shift */

.fade-in {
    animation: fade-in 600ms;
    animation-fill-mode: backwards;
}

.no-animation-on-load {
    animation-iteration-count: 0;
}

.opacity-0 {
    opacity: 0;
}

/* Responsive Styles */

@media screen and (min-height: 800px) {
    footer {
        margin-bottom: 16px;
    }
}

@media (hover: hover) and (pointer: fine) {
    x-instructions:not([drop-peer]):not([drop-bg]):before {
        content: attr(desktop);
    }
}

/* Constants */

:root {
    --icon-size: 24px;
    --peer-width: 120px;
    color-scheme: light dark;
}

/*
    Color Themes
*/

/* Default colors */
body {
    /* Constant colors */
    --primary-color: #4285f4;
    --paired-device-color: #00a69c;
    --public-room-color: #db8500;
    --accent-color: var(--primary-color);
    --ws-peer-color: #ff6b6b;
    --btn-disabled-color: #5B5B66;
    /* shadows */
    --shadow-color-rgb: var(--text-color);
    --shadow-color-cover-rgb: var(--bg-color);
}

/* Light theme colors */
body {
    --text-color: 51,51,51;
    --dialog-bg-color: #fff;
    --bg-color: 255,255,255;
    --bg-color-secondary: #f2f2f2;
    --border-color: rgb(169, 169, 169);
    --badge-color: #a5a5a5;

    --shadow-color-secondary-rgb: 0,0,0;
    --shadow-color-secondary-cover-rgb: 242,242,242;
    --shadow-color-dialog-rgb: 0,0,0;
    --shadow-color-dialog-cover-rgb: 242,242,242;
}

/* Dark theme colors */
body.dark-theme {
    --text-color: 238,238,238;
    --dialog-bg-color: #121212;
    --bg-color: 0,0,0;
    --bg-color-secondary: #262628;
    --border-color: rgb(91, 91, 91);
    --badge-color: #717171;

    --shadow-color-secondary-rgb: 255,255,255;
    --shadow-color-secondary-cover-rgb: 38,38,38;
    --shadow-color-dialog-rgb: 255,255,255;
    --shadow-color-dialog-cover-rgb: 38,38,38;
}

/* Styles for users who prefer dark mode at the OS level */
@media (prefers-color-scheme: dark) {

    /* defaults to dark theme */
    body {
        --text-color: 238,238,238;
        --dialog-bg-color: #121212;
        --bg-color-secondary: #262628;
        --bg-color: 0,0,0;
        --border-color: rgb(91, 91, 91);
        --badge-color: #717171;

        --shadow-color-secondary-rgb: 255,255,255;
        --shadow-color-secondary-cover-rgb: 38,38,38;
        --shadow-color-dialog-rgb: 255,255,255;
        --shadow-color-dialog-cover-rgb: 38,38,38;
    }


    /* Override dark mode with light mode styles if the user decides to swap */
    body.light-theme {
        --text-color: 51,51,51;
        --dialog-bg-color: #fff;
        --bg-color: 255,255,255;
        --bg-color-secondary: #f2f2f2;
        --border-color: rgb(169, 169, 169);
        --badge-color: #a5a5a5;

        --shadow-color-secondary-rgb: 0,0,0;
        --shadow-color-secondary-cover-rgb: 242,242,242;
        --shadow-color-dialog-rgb: 0,0,0;
        --shadow-color-dialog-cover-rgb: 242,242,242;
    }
}

/* Colored Elements */
body {
    color: rgb(var(--text-color));
    background-color: rgb(var(--bg-color));
    transition: background-color 0.5s ease;
}

x-dialog x-paper {
    background-color: var(--dialog-bg-color);
}

.textarea {
    color: rgb(var(--text-color)) !important;
    background-color: var(--bg-color-secondary) !important;
}

.textarea * {
    margin: 0 !important;
    padding: 0 !important;
    color: unset !important;
    background: unset !important;
    border: unset !important;
    opacity: unset !important;
    font-family: inherit !important;
    font-size: inherit !important;
    font-style: unset !important;
    font-weight: unset !important;
}

/* Gradient for wifi-tether icon */
#primaryGradient .start-color {
    stop-color: var(--primary-color);
}

@supports (stop-color: color-mix(in srgb, blue 50%, black)) {
    #primaryGradient .start-color {
        stop-color: color-mix(in srgb, var(--primary-color) 80%, white);
    }
}

#primaryGradient .stop-color {
    stop-color: var(--primary-color);
}


/*
    Edge specific styles
*/
@supports (-ms-ime-align: auto) {

    html,
    body {
        overflow: hidden;
    }
}

/*
    Browser specific styles
*/

body {
    /* mobile viewport bug fix */
    min-height: -moz-available;          /* WebKit-based browsers will ignore this. */
    min-height: -webkit-fill-available;  /* Mozilla-based browsers will ignore this. */
    min-height: fill-available;
}

html {
    min-height: -moz-available;          /* WebKit-based browsers will ignore this. */
    min-height: -webkit-fill-available;  /* Mozilla-based browsers will ignore this. */
    min-height: fill-available;
}

/* webkit scrollbar style*/

::-webkit-scrollbar{
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-thumb{
    background: #bfbfbf;
    border-radius: 4px;
}

::-moz-selection,
::selection {
    color: black;
    background: var(--primary-color);
}

/* make elements with attribute contenteditable editable on older iOS devices.
See note here: https://developer.mozilla.org/en-US/docs/Web/CSS/user-select */
[contenteditable] {
    -webkit-user-select: text;
    user-select: text;
}

