/* Fonts
   Montserrat stands in for Gotham until we have the web licence.
   To switch, replace the first @font-face with Gotham Book (400) and
   Gotham Medium (600). */
@font-face {
    font-family: "Brand Sans";
    src: url("../fonts/montserrat-latin-400-600.woff2") format("woff2");
    font-weight: 400 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Bebas Neue";
    src: url("../fonts/bebas-neue-latin-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --font-sans: "Brand Sans", "Montserrat", Arial, sans-serif;
    --font-display: "Bebas Neue", Impact, sans-serif;

    --black: #000;
    --white: #fff;
    --grey-100: #f7f7f7;
    --grey-300: #dddddf;
    --grey-400: #939598;
    --grey-600: #6d6e71;
    --cyan: #00e0ff;
    --green: #00a651;
    --red: #ed1c24;
    --stable: #d1d3d4;
    --declined: #fbb040;
    --no-data: #f2fdff;

    --sidebar-width: 264px;
    --gutter: 36px;
}

/* Base */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: 600;
    line-height: 1.2;
    color: var(--black);
    background: var(--white);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ul {
    margin: 0;
}

ul {
    padding: 0;
    list-style: none;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Icons */
.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    display: block;
    flex: none;
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.icon--md {
    width: 18px;
    height: 18px;
}

.icon--lg {
    width: 20px;
    height: 20px;
}

.icon--accent {
    color: var(--cyan);
}

.platform-icon {
    display: block;
    flex: none;
    width: 16px;
    height: 16px;
}

/* Layout */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.main {
    min-width: 0;
    padding: 30px var(--gutter) 95px 28px;
}

/* Sidebar */
.sidebar {
    padding: 34px var(--gutter) 40px;
    background: var(--grey-100);
}

.sidebar__inner {
    position: sticky;
    top: 34px;
}

.search {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 42px;
    padding: 0 16px;
    background: var(--white);
    border-radius: 8px;
}

.search:focus-within {
    box-shadow: 0 0 0 1px var(--cyan);
}

.search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    font-size: 11.5px;
    background: none;
    border: 0;
    outline: none;
}

.search input::placeholder {
    color: var(--grey-600);
    opacity: 1;
}

.menu-label {
    margin: 48px 0 12px;
    font-size: 12px;
    color: var(--grey-600);
}

.nav {
    display: grid;
    gap: 8px;
}

.nav__link {
    display: flex;
    align-items: center;
    height: 44px;
    padding-left: 17px;
    font-size: 15px;
    border-radius: 7px;
    transition: background-color 0.15s;
}

.nav__link:hover,
.nav__link.active {
    background: var(--white);
}

.nav__icon {
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin-right: 11px;
}

.nav__link.active .nav__icon {
    color: var(--cyan);
}

.sidebar hr {
    margin: 30px 0;
    border: 0;
    border-top: 1px solid var(--grey-300);
}

/* Header */
.brand {
    display: flex;
    justify-content: center;
    /* centre the logo on the page rather than the content column */
    margin-right: calc(var(--sidebar-width) + 28px - var(--gutter));
}

.brand img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Sections */
.section-title {
    margin-top: 52px;
    font-family: var(--font-display);
    font-size: 42px;
    font-weight: 400;
    line-height: 50px;
    text-transform: uppercase;
}

.section-divider {
    margin: 50px calc(var(--gutter) * -1) 0 -28px;
    border: 0;
    border-top: 1px solid var(--grey-300);
}

.seo .section-title {
    margin-top: 21px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 15px;
}

/* Segmented control / tabs */
.segmented {
    display: inline-flex;
    gap: 5px;
    padding: 4px 3px;
    background: var(--grey-100);
    border-radius: 7px;
}

.segmented--small {
    border-radius: 5px;
}

.segmented__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-width: 61px;
    height: 32px;
    padding: 0 10px;
    font-size: 11.5px;
    white-space: nowrap;
    color: var(--grey-600);
    background: none;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
}

.segmented__item:hover {
    color: var(--black);
}

.segmented__item[aria-pressed="true"] {
    background: var(--white);
}

.segmented__item--instagram {
    min-width: 116px;
}

.segmented__item--tiktok,
.segmented__item--wide {
    min-width: 88px;
}

.date-range {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 297px;
    height: 40px;
    padding: 0 16px;
    font-size: 11.5px;
    white-space: nowrap;
    color: var(--grey-600);
    background: var(--grey-100);
    border: 0;
    border-radius: 7px;
}

.date-range__divider {
    height: 22px;
    margin: 0 15px;
    border-left: 1px solid var(--grey-300);
}

.select {
    position: relative;
}

.select select {
    width: 85px;
    height: 40px;
    padding: 0 20px 0 10px;
    font-size: 11.5px;
    color: var(--grey-600);
    background: var(--white);
    border: 1px solid var(--grey-300);
    border-radius: 4px;
    cursor: pointer;
    appearance: none;
}

.select .icon {
    position: absolute;
    top: 50%;
    right: 11px;
    width: 8px;
    height: 8px;
    color: var(--grey-600);
    transform: translateY(-50%);
    pointer-events: none;
}

/* Tabs
   Each tab group is a set of hidden radio buttons placed before the panels,
   so CSS can switch the panels without any JavaScript. */
.tab-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.tab-panel,
.metric-view {
    display: none;
}

/* platform tabs */
#platform-all:checked ~ #panel-all,
#platform-instagram:checked ~ #panel-instagram,
#platform-tiktok:checked ~ #panel-tiktok {
    display: block;
}

#platform-all:checked ~ .toolbar [for="platform-all"],
#platform-instagram:checked ~ .toolbar [for="platform-instagram"],
#platform-tiktok:checked ~ .toolbar [for="platform-tiktok"] {
    background: var(--white);
}

#platform-all:focus-visible ~ .toolbar [for="platform-all"],
#platform-instagram:focus-visible ~ .toolbar [for="platform-instagram"],
#platform-tiktok:focus-visible ~ .toolbar [for="platform-tiktok"] {
    outline: 2px solid var(--cyan);
    outline-offset: 1px;
}

/* metric tabs (the top row of cards) */
#metric-followers:checked ~ .tab-panel .metric-view--followers,
#metric-shares:checked ~ .tab-panel .metric-view--shares,
#metric-likes:checked ~ .tab-panel .metric-view--likes,
#metric-comments:checked ~ .tab-panel .metric-view--comments {
    display: block;
}

#metric-followers:checked ~ .tab-panel label.card--followers,
#metric-shares:checked ~ .tab-panel label.card--shares,
#metric-likes:checked ~ .tab-panel label.card--likes,
#metric-comments:checked ~ .tab-panel label.card--comments {
    border-color: var(--cyan);
}

#metric-followers:checked ~ .tab-panel .card--followers .icon,
#metric-shares:checked ~ .tab-panel .card--shares .icon,
#metric-likes:checked ~ .tab-panel .card--likes .icon,
#metric-comments:checked ~ .tab-panel .card--comments .icon {
    color: var(--cyan);
}

#metric-followers:focus-visible ~ .tab-panel label.card--followers,
#metric-shares:focus-visible ~ .tab-panel label.card--shares,
#metric-likes:focus-visible ~ .tab-panel label.card--likes,
#metric-comments:focus-visible ~ .tab-panel label.card--comments {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

/* Stat cards */
.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 18px;
    margin-top: 28px;
}

.card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 176px;
    padding: 11px 14px 14px;
    background: var(--grey-100);
    border: 1px solid transparent;
    border-radius: 10px;
    container: card / inline-size;
}

.card.active {
    border-color: var(--cyan);
}

label.card {
    cursor: pointer;
    transition: border-color 0.15s;
}

label.card:hover {
    border-color: rgba(0, 224, 255, 0.45);
}

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 20px;
}

.card__title {
    font-size: 14px;
    font-weight: 600;
    line-height: 17px;
}

.card__body {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    column-gap: 7px;
}

.card__value {
    font-size: 56px;
    line-height: 62px;
}

.card--target .card__value {
    color: var(--grey-400);
}

.card__change {
    margin-top: -1px;
    font-size: 15px;
    font-weight: 400;
    line-height: 18px;
    white-space: nowrap;
}

/* keep the value and its change on one line in narrow cards */
@container card (max-width: 245px) {
    .card__value {
        font-size: 46px;
        line-height: 52px;
    }
}

@container card (max-width: 205px) {
    .card__value {
        font-size: 38px;
        line-height: 44px;
    }
}

.up {
    color: var(--green);
}

.down {
    color: var(--red);
}

/* Boxes (chart and table) */
.box {
    margin-top: 20px;
    border: 1px solid var(--grey-300);
    border-radius: 10px;
}

.box + .box {
    margin-top: 18px;
}

.seo .box {
    margin-top: 22px;
}

.box__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 10px 0 24px;
}

.box__title {
    font-size: 20px;
    font-weight: 600;
    line-height: 24px;
}

.box__tools {
    display: flex;
    align-items: center;
    gap: 11px;
}

/* Charts */
.chart-wrap {
    padding: 0 21px 0 24px;
}

.chart {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.chart text {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    fill: var(--grey-600);
}

.chart .axis,
.chart .grid line {
    stroke: var(--grey-600);
    stroke-width: 0.5;
    stroke-dasharray: 3;
    opacity: 0.6;
    vector-effect: non-scaling-stroke;
}

.chart .line {
    fill: none;
    stroke: var(--cyan);
    stroke-width: 1;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.chart .dots {
    fill: var(--cyan);
}

.bar-improved {
    fill: var(--cyan);
}

.bar-stable {
    fill: var(--stable);
}

.bar-declined {
    fill: var(--declined);
}

.bar-empty {
    fill: var(--no-data);
    stroke: var(--grey-600);
    stroke-width: 0.5;
    stroke-dasharray: 3;
    opacity: 0.9;
    vector-effect: non-scaling-stroke;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 13px;
    padding: 12px 24px 13px;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
}

.legend--bars {
    padding-top: 14px;
}

.legend__item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.legend__item::before {
    content: "";
    width: 12px;
    height: 5px;
    background: var(--cyan);
}

.legend__item--line::before {
    width: 13px;
    height: 3px;
    background: #72ecfe;
}

.legend__item--stable::before {
    background: var(--stable);
}

.legend__item--declined::before {
    background: var(--declined);
}

.legend__item--empty::before {
    background: var(--no-data);
    border: 1px dashed var(--grey-600);
}

/* Channel table */
.table-wrap {
    padding: 13px 21px 11px 24px;
    overflow-x: auto;
}

.table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 16px;
}

.table th,
.table td {
    padding: 0;
    text-align: center;
}

.table th:first-child {
    width: 51%;
    text-align: left;
}

.table thead th {
    height: 41px;
    font-weight: 600;
    white-space: nowrap;
}

.table tbody th,
.table tbody td {
    height: 48px;
    font-weight: 400;
}

.table tbody tr {
    border-bottom: 1px solid var(--grey-300);
}

.table tfoot th,
.table tfoot td {
    height: 48px;
    font-weight: 600;
}

.table--single tbody tr:last-child {
    border-bottom: 0;
}

.channel {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding-left: 4px;
}

.channel .platform-icon {
    width: 20px;
    height: 20px;
}

/* Responsive */
@media (max-width: 1280px) {
    .brand {
        margin-right: 0;
    }

    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar-width: 220px;
        --gutter: 20px;
    }

    .main {
        padding-left: 20px;
    }

    .section-divider {
        margin-left: -20px;
    }

    .chart-wrap {
        overflow-x: auto;
    }

    .chart {
        min-width: 720px;
    }
}

@media (max-width: 720px) {
    :root {
        --gutter: 16px;
    }

    .app {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        padding: 16px;
    }

    .sidebar__inner {
        position: static;
    }

    .menu-label {
        margin-top: 20px;
    }

    .nav {
        grid-template-columns: 1fr 1fr;
    }

    .sidebar hr {
        margin: 16px 0;
    }

    .main {
        padding: 24px 16px 48px;
    }

    .section-divider {
        margin-left: -16px;
    }

    .card {
        min-height: 140px;
    }

    .card__value {
        font-size: 42px;
        line-height: 48px;
    }

    .date-range {
        min-width: 0;
    }

    .box__head,
    .chart-wrap,
    .legend,
    .table-wrap {
        padding-left: 16px;
        padding-right: 16px;
    }
}

@media (max-width: 420px) {
    .cards {
        grid-template-columns: 1fr;
    }

    .toolbar {
        align-items: stretch;
    }

    .segmented,
    .date-range {
        width: 100%;
    }

    .segmented__item {
        flex: 1;
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
