// Copyright 2020 Thomas Hintz
//
// This file is part of the Alpha Centauri Farming project.
//
// The Alpha Centauri Farming project is free software: you can
// redistribute it and/or modify it under the terms of the GNU General
// Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// The Alpha Centauri Farming project is distributed in the hope that
// it will be useful, but WITHOUT ANY WARRANTY; without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE.  See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with the Alpha Centauri Farming project.  If not, see
// <https://www.gnu.org/licenses/>.

@font-face {
  font-family: 'IndieFlower-Regular';
  src: url('../assets/font/IndieFlower-Regular.woff2') format('woff2'),
       url('../assets/font/IndieFlower-Regular.woff') format('woff'),
       url('../assets/font/IndieFlower-Regular.ttf') format('truetype');
}

@font-face {
  font-family: 'LibreBaskerville-Regular';
  src: url('../assets/font/LibreBaskerville-Regular.woff2') format('woff2'),
       url('../assets/font/LibreBaskerville-Regular.woff') format('woff'),
       url('../assets/font/LibreBaskerville-Regular.ttf') format('truetype');
}

@import './foundation/foundation';

// Global styles
@include foundation-global-styles;
@include foundation-forms;
@include foundation-typography;

// Grids
@include foundation-xy-grid-classes;

// Generic components
@include foundation-button;
@include foundation-button-group;
@include foundation-close-button;
@include foundation-label;
@include foundation-progress-bar;
// @include foundation-slider;
@include foundation-switch;
@include foundation-table;
// Basic components
@include foundation-badge;
@include foundation-breadcrumbs;
@include foundation-callout;
@include foundation-card;
@include foundation-dropdown;
@include foundation-pagination;
@include foundation-tooltip;

// Containers
// @include foundation-accordion;
// @include foundation-media-object;
// @include foundation-orbit;
// @include foundation-responsive-embed;
// @include foundation-tabs;
// @include foundation-thumbnail;
// Menu-based containers
@include foundation-menu;
@include foundation-menu-icon;
// @include foundation-accordion-menu;
// @include foundation-drilldown-menu;
// @include foundation-dropdown-menu;

// Layout components
// @include foundation-off-canvas;
// @include foundation-reveal;
// @include foundation-sticky;
// @include foundation-title-bar;
// @include foundation-top-bar;

// Helpers
@include foundation-float-classes;
// @include foundation-flex-classes;
@include foundation-visibility-classes;
// @include foundation-prototype-classes;

@include add-foundation-colors;

$color-primary-dark: #49B383;

$color-subdued: #f2f2f2;
$color-light-primary: #2196f3;

$dark-color: #7F3125;
$light-color: #FFA496;
$orange-color: #FF624A;

$tab-margin: 0.3rem;

.tractor {
    opacity: 0.5;
    z-index: -2;
    position: absolute;
    bottom: 0;
    right: 0;
    img {
        @include breakpoint(small only) {
            width: 90vw; }
        width: 90vh; }
}

.tractor.spikes {
    opacity: 1;
    overflow: hidden;
    img {
        animation: spikes 20s linear 2;
        transform-origin: 40% 67.15%; }
}

@keyframes spikes {
    100% { transform:rotate(360deg); }
}

.background-heading {
    z-index: -1;
    position: absolute;
    text-align: center;
    width: 100%;
    top: 0;
    left: 0;
    h1 {
        color: rgba(127, 49, 37, 0.8);
        text-shadow: 1px 4px 6px $secondary-color, 0 0 0 #000, 1px 4px 6px $secondary-color;
        background: url('../assets/img/mars-texture.png');
        background-repeat: repeat-x;
        background-position: 0 0;
        text-transform: uppercase;
        background-clip: text;
        font-smoothing: antialiased;
        text-fill-color: transparent;
        -webkit-text-fill-color: transparent;
        font-weight: bold;
        font-size: 2.5rem; }
}

.flex-fullcenter {
    background: $secondary-color;
    height: 100vh;
    position: relative;
    z-index: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center; }

.view-container {
    max-height: 90vh;
    overflow: auto;
    border: 0.3rem solid $dark-color;
    background: linear-gradient(180deg, $light-color 0%, $orange-color 100%);
    padding: 1rem;
    border-radius: 0.5rem; }

.column {
    padding-right: 0; }

.column-no-padding {
    padding-left: 0; }

.row.full-width {
    max-width: 100%;
    width: 100%; }

.space {
    font-family: 'IndieFlower-Regular';
    // font-family: 'LibreBaskerville-Regular';
    flex-grow: 1;
    flex-basis: 0;
    padding: 3px;
    background-color: white;
    border: 1px solid black;
    position: relative;
    @include breakpoint(medium down) {
        font-size: 4px; }
    @include breakpoint(large) {
        font-size: 14px; }
    text-shadow: 0px 0px 2px black;
}

.space-description {
    display: none; /* TODO re-show for larger screens */
    position: absolute;
    bottom: 3px;
    overflow: hidden;
    max-height: 27px;
    font-size: 4px; }

.game-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh; }

.row-spaces {
    @include breakpoint(small only) {
        height: 2rem; }
    @include breakpoint(landscape) {
        @include breakpoint(medium) {
            height: 2rem; }
        @include breakpoint(large) {
            height: 5rem; }
    }
    @include breakpoint(portrait) {
        @include breakpoint(medium) {
            height: 5rem; }
    }
    .space {
        height: 100%; }
    .flex-row {
        height: 100%; }
}

.mid-row-container {
    flex-grow: 1; }

.action {
    .space {
        font-size: 15px; }

    .space-description {
        display: block;
        max-height: 81px;
        font-size: 14px; }
}

.farms-ridge {
    display: inline-flex;
    flex-direction: column;
    font-size: 1rem;
    padding: 0.2rem;
    background-color: hsla(0, 0%, 50%, 0.3);
    border-radius: 0.2rem;
    align-items: center;
    margin: 0.2rem;
    .num-cows {
        font-size: 0.8rem;
    }
}

.player {
    display: inline-block;
    @include breakpoint(medium down) {
        height: 7px;
        width: 7px;
        border-radius: 4px; }
    @include breakpoint(large) {
        height: 16px;
        width: 16px;
        border-radius: 12px; }
    margin-top: 4px;
    margin-left: 5px; }

.player-current {
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    transition: all 0.3s ease-in-out; }

.player-current::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  top: 0;
  left: 0;
  background-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0px 5px $primary-color;
  animation: die-pulse 2s ease-in-out infinite; }

.player-selectable {
    border: 4px solid #ff816e;
    cursor: pointer;
    height: 26px;
    width: 26px; }

.player-selectable:hover {
    border: 4px solid $color-light-primary; }

.player-selectable input[type=checkbox] {
    cursor: pointer;
    opacity: 0; }

.player-selected {
    border: 4px solid $color-light-primary; }

.player-green {
    background-color: green; }
.player-red {
    background-color: red; }
.player-blue {
    background-color: blue; }
.player-yellow {
    background-color: yellow; }
.player-black {
    background-color: black; }
.player-none {
    background-color: #f2f2f2; }

.tab .player {
    height: 27px;
    width: 27px;
    border-radius: 15px;
    margin-right: 0.5rem; }

.player-trade-resources input {
    margin: 0; }

.player-trade-resources .resource-unit {
    display: inline-block;
    margin-bottom: 0.3rem;
    width: 4rem; }

.resource-unit.double-width {
    width: 84px;
}

.resource-unit.double-width .button:last-child {
    margin-left: 0.2rem;
}

.player-trade-resources img {
    margin-top: 0.2rem;
    margin-bottom: 0.2rem; }

.trade-player-container {
    border: 0.2rem solid $dark-color;
    border-radius: 0.2rem;
    background: #ccc;
    padding: 0.3rem;
    .button {
        margin: 0; }
}

$trade-margin: 3rem;
.resources-to-trade {
    margin-left: 0.5rem;
    visibility: hidden;
    .resource-unit {
        position: relative;
        margin-top: $trade-margin / 2;
        margin-bottom: $trade-margin / 2;
    }

    .trade-asset-cancel {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        color: red;
        padding: 0.2rem;
        display: none;
        cursor: pointer;
        opacity: 0.7;
        svg {
            width: 100%;
            height: 100%;
        }
    }

    .trade-to {
        margin-top: ($trade-margin / 2) - 1.2;
        margin-bottom: ($trade-margin / 2) + 1.2;
        visibility: visible;
    }

    .trade-to:hover .trade-asset-cancel {
        display: block;
    }
    .trade-from:hover .trade-asset-cancel {
        display: block;
    }

    .trade-from {
        margin-bottom: ($trade-margin / 2) - 1.2;
        margin-top: ($trade-margin / 2) + 1.2;
        visibility: visible;
    }
}

.card-id {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.9rem;
}

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

.mid-col {
    height: 100%;
    display: flex;
    flex-direction: column; }

.mid-row {
    height: 100%;
    display: flex;
    flex-direction: row; }

.center-board {
    flex-grow: 1;
    flex-basis: 0;
    position: relative;
    z-index: 0;
    background-color: $secondary-color;
    .tractor img {
        opacity: 0.5;
        @include breakpoint(small only) {
            width: 60vw; }
        width: 50vh; }
}

.resource-unit {
    position: relative;
    text-align: center;
    margin-right: 0.5rem;
    width: 40px;
    padding: 3px;
    img {
        height: 34px; }
}

.resource-doubled {
    position: absolute;
    top: -0.7rem;
    right: -0.2rem;
    color: blue;
    font-size: 1.4rem;
    padding: 0.1rem;
    transform: rotate(17deg);
    svg {
        filter: drop-shadow( 1px 1px 1px rgba(0, 0, 0, .7));
    }
}

.resource-unit-container {
    display: flex;
    flex-direction: row; }

#message-panel {
    display: none;
    position: absolute;
    background: white; }

#message-panel .space {
    width: 160px; }

#message-panel div div .space-description {
    font-size: 16px;
    margin: 0.4rem;
    max-height: 140px; }

#message-panel div div center {
    margin: 0.4rem;
    font-size: 20px;
    font-weight: bold; }

.space-type-hay {
    background-color: hsla(120, 100%, 25%, 0.19); }

.space-type-hay::after {
    background: url('../assets/img/hay.svg') repeat;
    content: '';
    width: 100%;
    height: 100%;
    opacity: 0.2;
    z-index: -1;
    position: absolute;
    filter: invert(42%) sepia(93%) saturate(1352%) hue-rotate(87deg) brightness(119%) contrast(119%);
    background-size: auto 100%;
    top: 0;
    left: 0; }

.space-type-cherry {
    background-color: hsla(0, 100%, 40%, 0.28); }

.space-type-cherry::after {
    background: url('../assets/img/fruit.svg') repeat;
    content: '';
    width: 100%;
    height: 100%;
    opacity: 0.1;
    z-index: -1;
    position: absolute;
    filter: invert(13%) sepia(54%) saturate(6280%) hue-rotate(358deg) brightness(98%) contrast(123%);
    background-size: auto 50%;
    background-position: right;
    top: 0;
    left: 0; }

.space-type-apple {
    background-color: hsla(0, 100%, 40%, 0.28); }

.space-type-apple::after {
    background: url('../assets/img/fruit.svg') repeat;
    content: '';
    width: 100%;
    height: 100%;
    opacity: 0.1;
    z-index: -1;
    position: absolute;
    filter: invert(13%) sepia(54%) saturate(6280%) hue-rotate(358deg) brightness(98%) contrast(123%);
    background-size: auto 50%;
    background-position: right;
    top: 0;
    left: 0; }

.space-type-wheat {
    background-color: hsla(50, 97%, 48%, 0.22); }

.space-type-wheat::after {
    background: url('../assets/img/wheat.svg') repeat;
    content: '';
    width: 100%;
    height: 100%;
    opacity: 0.2;
    z-index: -1;
    position: absolute;
    filter: invert(68%) sepia(58%) saturate(747%) hue-rotate(8deg) brightness(102%) contrast(106%);
    background-size: auto 110%;
    background-position: right;
    top: 0;
    left: 0; }

.space-type-corn {
    background-color: hsla(50, 97%, 48%, 0.22); }

.space-type-corn::after {
    background: url('../assets/img/wheat.svg') repeat;
    content: '';
    width: 100%;
    height: 100%;
    opacity: 0.2;
    z-index: -1;
    position: absolute;
    filter: invert(68%) sepia(58%) saturate(747%) hue-rotate(8deg) brightness(102%) contrast(106%);
    background-size: auto 110%;
    background-position: right;
    top: 0;
    left: 0; }

.space-type-cows {
    background-color: hsla(0, 25%, 43%, 0.49); }

.space-type-cows::after {
    background: url('../assets/img/cow.svg') repeat;
    content: '';
    width: 100%;
    height: 100%;
    opacity: 0.2;
    z-index: -1;
    position: absolute;
    filter: invert(43%) sepia(5%) saturate(4943%) hue-rotate(314deg) brightness(76%) contrast(75%);
    background-size: auto 35%;
    background-position: right;
    top: 0;
    left: 0; }

.space-type-buy {
    background-color: hsla(240, 100%, 85%, 0.15); }

.space-title {
    text-align: center;
    font-style: italic; }

.space-orientation-corner-tl {
    border-bottom: 0;
    border-right: 0; }

.space-orientation-corner-tr {
    border-bottom: 0; }

.space-orientation-top {
    border-right: 0; }

.space-orientation-left {
    border-bottom: 0; }

.space-orientation-right {
    border-bottom: 0; }

.space-orientation-bottom {
    border-right: 0; }

.space-orientation-corner-bl {
    border-right: 0; }

.card {
    background: inherit;
    border: 0;
    margin: 0; }

.card p {
    text-align: center;
    margin-bottom: 2px;}

.card-divider {
    padding: 0.5rem 0 0.5rem 0;
    background: none;
    font-weight: bold;
    font-size: 1.5rem; }

.card-action {
    margin-bottom: 0;
    border-top: 1px dashed black;
    padding-top: 0.8rem;
    margin-top: 0.4rem; }

.card-action label {
    margin-bottom: 0; }

.card-action input {
    margin-bottom: 0; }

.card-action button {
    margin-bottom: 0; }

.card-action form {
    margin-bottom: 0; }

.money input[type="number"] {
    float: unset;
    width: 4rem;
    display: unset;
    text-align: right; }

.messages {
    height: 140px;
    overflow: auto;}

.card-select {
    height: 10rem;
    background: white;
    padding: 0.4rem;
    list-style: none inside none;
    margin-left: 0;
    overflow-y: auto;
    border: 1px solid silver; }

.card-select li {
    cursor: pointer; }

.card-select-selected {
    background: #dae0ff; }

.die {
    margin-bottom: 1rem;
    width: 100px;
    height: 100px;
    background: lightyellow;
    position: relative;
    border-radius: 10px;
    border: 1px solid black; }

.die-selected {
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    transition: all 0.3s ease-in-out; }

.die-selected::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  border-radius: 5px;
  box-shadow: 0 6px 15px $primary-color;
  animation: die-pulse 2s ease-in-out infinite; }

@keyframes die-pulse {
    0% {
        opacity: 0; }
    50% {
        opacity: 1; }
   100% {
        opacity: 0; }
}

.die-container {
    display: flex;
    justify-content: center; }

.die-face {
    background: black;
    width: 20px;
    height: 20px;
    border-radius: 20px;
    position: absolute; }

.face-1 {
    top: 40px;
    left: 40px; }

.face-21 {
    top: 15px;
    left: 15px; }

.face-22 {
    top: 62px;
    left: 62px; }

.face-52 {
    top: 15px;
    left: 62px; }

.face-54 {
    top: 62px;
    left: 15px; }

.face-63 {
    top: 40px;
    left: 15px; }

.face-64 {
    top: 40px;
    left: 62px; }

.center {
    text-align: center; }

.menu.icons a {
    padding: 0.5rem 0.7rem; }

@include breakpoint(portrait) {
    .menu.vertical {
        display: none; }

    .menu {
        margin-left: $tab-margin;
        margin-right: $tab-margin; }

}

@include breakpoint(landscape) {
    .menu.horizontal {
        display: none; }

    .menu {
        margin-left: $tab-margin; }

    .center-board > .grid-x {
        height: 100%; }

    .center-board-container {
        display: flex;
        align-items: center;
        height: 100%; }

}

.center-board > .grid-x {
    @include breakpoint(medium down) {
        max-width: 30rem; }
    @include breakpoint(large) {
        font-size: 23px;
        width: 100%; }
    margin-left: auto;
    margin-right: auto; }

.tab-container {
    overflow-y: auto;
    max-height: 80vh;
    @include breakpoint(medium down) {
        flex-grow: 2;
        max-width: 82vw;
    }
    @include breakpoint(large) {
        width: 26rem;
    }
}

.trade-tab {
    min-width: 26rem;
}

.static-tab-container {
    overflow-y: auto;
    max-height: 80vh;
    width: 26rem;
}

.tab {
    $tab-border: 0.3rem solid $primary-color;
    @include breakpoint(portrait) {
        margin-left: $tab-margin;
        border-top: $tab-border;
        border-bottom: $tab-border; }
    @include breakpoint(landscape) {
        border-left: $tab-border;
        border-right: $tab-border; }
    margin-right: $tab-margin;
    background: $light-color;
    padding: 0.5rem;
    display: none; }

.tab.show {
    display: block; }

.turn-container .button {
    margin: 0; }

.harvest-table {
    overflow: auto;
    max-width: 75vw;
}

.board-heading {
    z-index: -1;
    position: absolute;
    opacity: 0.5;
    text-align: center;
    width: 100%;
    bottom: 0;
    h1 {
        color: rgba(127, 49, 37, 0.8);
        text-shadow: 1px 4px 6px $secondary-color, 0 0 0 #000, 1px 4px 6px $secondary-color;
        background: url('../assets/img/mars-texture.png');
        background-repeat: repeat-x;
        background-position: 0 0;
        text-transform: uppercase;
        background-clip: text;
        font-smoothing: antialiased;
        text-fill-color: transparent;
        -webkit-text-fill-color: transparent;
        font-weight: bold;
        font-size: 1rem; }
}

.game-card {
    padding: 0.3rem;
    background: rgba(255, 255, 224, 0.5);
    z-index: 1;
    border: 0.15rem solid $primary-color;
    position: relative; }

.game-card::after {
    background: url('../assets/img/mars-texture.png') repeat;
    content: '';
    width: 100%;
    height: 100%;
    opacity: 0.3;
    z-index: -1;
    position: absolute;
    top: 0;
    left: 0; }

.flex {
    display: flex;
    flex-direction: row;
    align-items: center; }

.green svg {
    color: green; }

.red svg {
    color: red; }

.spacer {
    margin-top: 1rem; }

.clear-background {
    background: white; }

.harvest-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.3rem;
    border: 0.15rem solid $primary-color;
    h1 {
        font-weight: bold;
        text-transform: uppercase; }
    button {
        margin-top: 1rem; }
    img {
        @include breakpoint(medium down) {
            width: 20%; }
        @include breakpoint(large) {
            width: 30%; }
    }
    .harvest-card-contents {
        width: 100%; }
}

.alert-overlay {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.5);
    width: 100vw;
    height: 100vh;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center; }

.alert-overlay.hidden {
    display: none; }

.alert-overlay-hide {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: white; }

.alert-overlay-contents {
    max-height: 90vh;
    overflow: auto;
    background: $light-color;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center; }

.moving {
    display: flex;
    justify-content: center;
    .action {
        @include breakpoint(small only) {
            width: 100%; }
        @include breakpoint(medium) {
            width: 15rem; }
    }
}

.button.shadow {
    box-shadow: 0 0 4px black; }

$intro-time: 6s;
.intro-text {
    opacity: 0;
    height: 50vh;
    width: 90vw;
    max-width: 30rem;
    font-size: 1.4rem;
    text-shadow: 1px 1px 0px black;
    margin-top: 1rem;
    margin-bottom: 1rem;
    animation-delay: 1s;
    animation: intro-fade $intro-time forwards;
    .game-card {
        border: 0.15rem solid black; }
}

@keyframes intro-fade {
    0% {
        opacity: 0; }
    15% {
        opacity: 1; }
    85% {
        height: 50vh;
        opacity: 1 }
    100% {
        height: 0;
        opacity: 0 }
}

.button.intro {
    opacity: 0.8;
    animation: button-fade 2s forwards;
    animation-delay: $intro-time - 1; }

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

.tractor.intro {
    opacity: 0.4;
    animation: tractor-fade 2s forwards;
    animation-delay: $intro-time - 1; }

@keyframes tractor-fade {
    0% {
        opacity: 0.4; }
   100% {
        opacity: 0.8; }
}

.credits img {
    height: 34px; }

.fa-arrow-circle-left {
    cursor: pointer;
    margin-right: 0.5rem; }

.info-bar {
    @include breakpoint(landscape) {
        position: absolute; }
    text-align: center;
    padding: $tab-margin;
    height: 2rem; }

.new-game-submit-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .button {
        margin: 0; }
}

.hidden {
    display: none; }

.space-icon {
    position: absolute;
    bottom: 0;
    opacity: 0.5;
    right: 4px; }

.error {
    font-size: 1.2rem;
    color: red;
    font-weight: bold }


.small-text {
    @include breakpoint(small only) {
        font-size: 0.9rem; }
    @include breakpoint(medium) {
        font-size: 1.2rem; }
}

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

.pad-right {
    padding-right: 0.3rem; }

.sign-out-button {
    position: absolute;
    bottom: 1rem; }

.kick-player {
    cursor: pointer;
    color: red;
    margin-left: 0.2rem; }

ul {
    margin-left: 0;
    list-style-type: none; }

.font-preloader {
    font-family: 'IndieFlower-Regular';
    width: 0;
    height: 0; }